Repository navigation
chore: publish dev charts from main #155
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
Open
brendan-kellam
wants to merge
1
commit into
main
Choose a base branch
from
brendan/sou-2814-deploy-staging-from-the-helm-charts-main-branch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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,92 @@ | ||
| name: Publish Dev Chart | ||
|
|
||
| # Publishes each main commit as a uniquely versioned dev chart, then asks | ||
| # sourcebot-infra to pin staging to it. Dev charts go to a separate GHCR path and | ||
| # skip chart-releaser, so they don't appear in the customer-facing Helm repo. | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'charts/sourcebot/**' | ||
| - '.github/workflows/publish-dev-chart.yaml' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: publish-dev-chart | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish and notify | ||
| # A manual run can target any ref, and this deploys to staging. | ||
| if: github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Helm | ||
| uses: azure/setup-helm@v3 | ||
| with: | ||
| version: v3.13.2 | ||
|
|
||
| - name: Install helm-unittest plugin | ||
| run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v1.0.0 | ||
|
|
||
| - name: Update dependencies | ||
| run: helm dependency update charts/sourcebot/ | ||
|
|
||
| - name: Run helm lint | ||
| run: helm lint charts/sourcebot/ -f charts/sourcebot/values.lint.yaml | ||
|
|
||
| - name: Run unit tests | ||
| run: helm unittest charts/sourcebot/ | ||
|
|
||
| - name: Set dev version | ||
| id: version | ||
| run: | | ||
| BASE_VERSION=$(yq e '.version' charts/sourcebot/Chart.yaml) | ||
| # The `g` prefix keeps this valid SemVer: a numeric identifier can't have | ||
| # a leading zero, and a short SHA can be all digits. | ||
| VERSION="${BASE_VERSION}-main.g${GITHUB_SHA::7}" | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Dev chart version: $VERSION" | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Package and push | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| helm package charts/sourcebot/ --version "$VERSION" | ||
| helm push "sourcebot-${VERSION}.tgz" oci://ghcr.io/sourcebot-dev/sourcebot-helm-chart/dev-charts | ||
|
|
||
| - name: Generate GitHub App token | ||
| id: generate_token | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ secrets.RELEASE_APP_ID }} | ||
| private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} | ||
| owner: sourcebot-dev | ||
| repositories: sourcebot-infra | ||
|
|
||
| - name: Notify sourcebot-infra | ||
| env: | ||
| GH_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| jq -n --arg version "$VERSION" \ | ||
| '{event_type: "chart-main-published", client_payload: {version: $version}}' \ | ||
| | gh api --method POST repos/sourcebot-dev/sourcebot-infra/dispatches --input - | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Queue pending runs if every main commit needs a chart.
When several qualifying pushes arrive before the running workflow finishes, GitHub cancels an existing pending run in this concurrency group.
cancel-in-progress: falseprotects only the running workflow. The canceled commit gets no dev chart or dispatch, contrary to the stated per-commit publishing goal. Usequeue: maxif intermediate commits must be published. (docs.github.com)