-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add codegen-check and helm-chart-update workflows #7
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| name: CI | ||
| # Jobs in this workflow are enforced as required status checks via branch protection on main. | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| # 'edited' is included so commitlint re-runs when PR title changes (used as squash commit message) | ||
| types: [opened, edited, synchronize, reopened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Check linter configuration | ||
| run: make lint-config | ||
|
|
||
| - name: Run linter | ||
| uses: golangci/golangci-lint-action@v9 | ||
| with: | ||
| version: v2.11.4 | ||
|
|
||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| go mod tidy | ||
| make test | ||
|
|
||
| codegen-check: | ||
| name: Verify Generated Code | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Run code generation | ||
| run: | | ||
| make manifests | ||
| make generate | ||
| make crd-docs | ||
|
|
||
| - name: Check for uncommitted changes | ||
| run: | | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "::error::Generated code is out of date. Please run 'make manifests generate crd-docs' and commit the changes." | ||
| echo "" | ||
| echo "Changed files:" | ||
| git status --short | ||
| echo "" | ||
| echo "Diff:" | ||
| git diff | ||
| exit 1 | ||
| fi | ||
| echo "Generated code is up to date." | ||
|
|
||
| commitlint: | ||
| name: Validate Commit Messages | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: .node-version | ||
|
|
||
| - name: Install commitlint | ||
| run: npm ci | ||
|
|
||
| - name: Lint commits | ||
| run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | ||
|
|
||
| test-e2e: | ||
| name: Test E2E | ||
| runs-on: ubuntu-latest | ||
| if: false # disabled until fixed | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Install kind | ||
| run: | | ||
| curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(go env GOARCH) | ||
| chmod +x ./kind | ||
| sudo mv ./kind /usr/local/bin/kind | ||
|
|
||
| - name: Verify kind installation | ||
| run: kind version | ||
|
|
||
| - name: Run E2E tests | ||
| run: | | ||
| go mod tidy | ||
| make test-e2e | ||
|
|
||
|
|
||
|
|
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| name: Update Helm Chart | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Build & Release"] | ||
| types: | ||
| - completed | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
| HELM_REPO: Interhyp/git-hubby-helm | ||
|
|
||
| jobs: | ||
| update-helm-chart: | ||
| name: Update Helm Chart | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | ||
| steps: | ||
| - name: Determine source branch | ||
| id: source | ||
| run: | | ||
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||
| echo "branch=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | ||
| echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "branch=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_OUTPUT" | ||
| echo "sha=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Checkout source repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ steps.source.outputs.branch }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Lowercase image name | ||
| run: echo "IMAGE_NAME=${IMAGE_NAME,,}" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Determine image version | ||
| id: version | ||
| run: | | ||
| if [[ "${{ steps.source.outputs.branch }}" == "main" ]]; then | ||
| git fetch --tags | ||
| LATEST_TAG=$(git tag --sort=-v:refname | head -1) | ||
| if [[ -n "$LATEST_TAG" ]]; then | ||
| VERSION="${LATEST_TAG#v}" | ||
| else | ||
| SHORT_SHA="$(git rev-parse --short HEAD)" | ||
| VERSION="main-${SHORT_SHA}" | ||
| fi | ||
| else | ||
| BRANCH="$(echo '${{ steps.source.outputs.branch }}' | sed 's|[^a-zA-Z0-9._-]|-|g' | cut -c1-50)" | ||
| SHORT_SHA="$(git rev-parse --short ${{ steps.source.outputs.sha }})" | ||
| VERSION="snapshot-${BRANCH}-${SHORT_SHA}" | ||
| fi | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "Image version: ${VERSION}" | ||
|
|
||
| - name: Checkout Helm chart repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| repository: ${{ env.HELM_REPO }} | ||
| token: ${{ secrets.HELM_CHART_PAT }} | ||
| path: helm-repo | ||
|
|
||
| - name: Generate Helm chart | ||
| run: make helm CHART_DIR=helm-repo/chart | ||
|
|
||
| - name: Update image tag in Helm chart | ||
| run: | | ||
| if [[ -f helm-repo/chart/values.yaml ]]; then | ||
| sed -i "s|tag:.*|tag: \"${{ steps.version.outputs.version }}\"|" helm-repo/chart/values.yaml | ||
| sed -i "s|repository:.*|repository: ${REGISTRY}/${IMAGE_NAME}|" helm-repo/chart/values.yaml | ||
| fi | ||
| if [[ -f helm-repo/chart/Chart.yaml ]]; then | ||
| sed -i "s|^appVersion:.*|appVersion: \"${{ steps.version.outputs.version }}\"|" helm-repo/chart/Chart.yaml | ||
| fi | ||
|
|
||
| - name: Determine target branch | ||
| id: branch | ||
| run: | | ||
| if [[ "${{ steps.source.outputs.branch }}" == "main" ]]; then | ||
| echo "name=update/v${{ steps.version.outputs.version }}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| BRANCH="$(echo '${{ steps.source.outputs.branch }}' | sed 's|[^a-zA-Z0-9._-]|-|g' | cut -c1-50)" | ||
| echo "name=snapshot/${BRANCH}" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
|
|
||
| - name: Commit and push changes | ||
| working-directory: helm-repo | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git checkout -b "${{ steps.branch.outputs.name }}" | ||
| git add -A | ||
| git diff --cached --quiet && echo "No changes to commit" && exit 0 | ||
| git commit -m "chore: update helm chart to version ${{ steps.version.outputs.version }}" | ||
| git push --force origin "${{ steps.branch.outputs.name }}" | ||
|
|
||
| - name: Create Pull Request for main branch | ||
| if: steps.source.outputs.branch == 'main' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.HELM_CHART_PAT }} | ||
| run: | | ||
| cd helm-repo | ||
| EXISTING_PR=$(gh pr list --head "${{ steps.branch.outputs.name }}" --json number --jq '.[0].number' 2>/dev/null || true) | ||
| if [[ -n "$EXISTING_PR" ]]; then | ||
| echo "PR #${EXISTING_PR} already exists, updating..." | ||
| gh pr edit "$EXISTING_PR" \ | ||
| --title "chore: update helm chart to v${{ steps.version.outputs.version }}" \ | ||
| --body "Automated Helm chart update from [git-hubby release v${{ steps.version.outputs.version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})" | ||
| else | ||
| gh pr create \ | ||
| --repo "${{ env.HELM_REPO }}" \ | ||
| --head "${{ steps.branch.outputs.name }}" \ | ||
| --base main \ | ||
| --title "chore: update helm chart to v${{ steps.version.outputs.version }}" \ | ||
| --body "Automated Helm chart update from [git-hubby release v${{ steps.version.outputs.version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})" \ | ||
| --label "automatic-update" \ | ||
| --draft | ||
| fi | ||
|
|
||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.