Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: publish helm #59

Merged
merged 7 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/bypass-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:
- 'mkdocs.yml'
- 'LICENSE'
- '.release-please-manifest.json'
- 'helm/trivy/Chart.yaml'
pull_request:
paths:
- '**.md'
- 'docs/**'
- 'mkdocs.yml'
- 'LICENSE'
- '.release-please-manifest.json'
- 'helm/trivy/Chart.yaml'
jobs:
test:
name: Test
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/publish-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
KIND_IMAGE: "kindest/node:v1.23.6@sha256:b1fa224cc6c7ff32455e0b1fd9cbfd3d3bc87ecaa8fcb06961ed1afb3db0f9ae"
jobs:
test-chart:
if: github.event_name == 'pull_request'
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand Down Expand Up @@ -48,8 +49,25 @@ jobs:
sed -i -e '136s,false,'true',g' ./helm/trivy/values.yaml
ct lint-and-install --validate-maintainers=false --charts helm/trivy

update-chart-version:
if: github.event_name == 'push'
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up Git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Get the tag without the 'v' prefix
run: echo "TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Create a PR
run: ./misc/helm-chart/create-pr.sh ${{ env.TAG }}

publish-chart:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
needs:
- test-chart
runs-on: ubuntu-20.04
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'mkdocs.yml'
- 'LICENSE'
- '.release-please-manifest.json' ## don't run tests for release-please PRs
- 'helm/trivy/Chart.yaml'
merge_group:
env:
GO_VERSION: '1.22'
Expand Down
42 changes: 42 additions & 0 deletions misc/helm-chart/create-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -e

VERSION=$1

# Update version in file
echo "Update Chart.yaml with Trivy $VERSION"
sed -i "s/version: [0-9]\+\.[0-9]\+\.[0-9]\+/version: $VERSION/" ./helm/trivy/Chart.yaml
sed -i "s/appVersion: [0-9]\+\.[0-9]\+\.[0-9]\+/appVersion: $VERSION/" ./helm/trivy/Chart.yaml

echo "Create PR for update Trivy $VERSION in the Helm Chart"

# Create a new branch
NEW_BRANCH="ci/bump-trivy-to-$VERSION"

echo "Creating new branch: $NEW_BRANCH"
git switch -c "$NEW_BRANCH"

# Create the title
TITLE="ci(helm): bump Trivy version to $VERSION"

# commit Helm Values with a new version
git add ./helm/trivy/Chart.yaml
git commit -m "$TITLE"

# Create the pull request description
PR_DESCRIPTION="# Description

This PR bumps Trivy up to the $VERSION version for the Helm chart."

echo "Pushing new branch to origin: $NEW_BRANCH"
git push origin "$NEW_BRANCH"

echo "Pull request title: $TITLE"

echo "Pull request description:"
echo "$PR_DESCRIPTION"

# Create a new pull request
echo "Creating pull request..."
gh pr create --base main --head "$NEW_BRANCH" --title "$TITLE" --body "$PR_DESCRIPTION" --repo "$GITHUB_REPOSITORY" --label "helm-chart"
Loading