Repository navigation
Publish the Helm chart as an OCI artifact on GHCR #1389
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 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,88 @@ | ||
| name: Helm chart publish | ||
|
|
||
| # Publishes charts/questarr as an OCI artifact on GHCR: | ||
| # helm install questarr oci://ghcr.io/doezer/charts/questarr --version <chart version> | ||
| # The chart `version` in Chart.yaml must be bumped on every chart change (helm-chart.yml and the | ||
| # bump-questarr-version skill already require it). A version that is already published is left | ||
| # untouched, so re-running this workflow or merging a change without a bump never overwrites a | ||
| # released chart. | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "charts/**" | ||
| - ".github/workflows/helm-publish.yml" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: helm-publish | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Harden the runner (Audit all outbound calls) | ||
| uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6.2.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Lint the chart | ||
| run: helm lint charts/questarr | ||
|
|
||
| - name: Read chart metadata | ||
| id: chart | ||
| run: | | ||
| echo "name=$(helm show chart charts/questarr | sed -n 's/^name: //p')" >> "$GITHUB_OUTPUT" | ||
| echo "version=$(helm show chart charts/questarr | sed -n 's/^version: //p')" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Log in to GHCR | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ACTOR: ${{ github.actor }} | ||
| run: echo "$GITHUB_TOKEN" | helm registry login ghcr.io --username "$ACTOR" --password-stdin | ||
|
|
||
| - name: Publish the chart if this version is new | ||
| env: | ||
| CHART_NAME: ${{ steps.chart.outputs.name }} | ||
| CHART_VERSION: ${{ steps.chart.outputs.version }} | ||
| OWNER: ${{ github.repository_owner }} | ||
| run: | | ||
| set -euo pipefail | ||
| owner_lc=$(echo "$OWNER" | tr '[:upper:]' '[:lower:]') | ||
| ref="oci://ghcr.io/${owner_lc}/charts" | ||
| # Only a "not found" answer from the registry means the version is free to publish. Any | ||
| # other failure (network, outage, rate limit, auth) must fail the job rather than risk | ||
| # overwriting a released chart version. | ||
| if out=$(helm show chart "${ref}/${CHART_NAME}" --version "${CHART_VERSION}" 2>&1); then | ||
| echo "Chart ${CHART_NAME} ${CHART_VERSION} is already published; nothing to do." | ||
| exit 0 | ||
| elif ! grep -qiE 'not found|manifest unknown|name unknown' <<<"$out"; then | ||
| echo "::error::Could not check for an existing chart: $out" | ||
| exit 1 | ||
| fi | ||
| helm package charts/questarr --destination dist-chart | ||
| helm push "dist-chart/${CHART_NAME}-${CHART_VERSION}.tgz" "${ref}" | ||
| { | ||
| echo "## Helm chart published" | ||
| echo | ||
| echo "- **Chart:** ${ref}/${CHART_NAME}" | ||
| echo "- **Version:** ${CHART_VERSION}" | ||
| echo | ||
| echo '```bash' | ||
| echo "helm install questarr ${ref}/${CHART_NAME} --version ${CHART_VERSION} --namespace questarr --create-namespace" | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" |
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 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 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
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.