add helm package workflow#166
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow intended to package the repository’s Helm chart and publish the resulting chart archive + index to the rustfs/operator-helm-package repository after a successful Docker image release.
Changes:
- Introduces
.github/workflows/helm-package.ymlto build a Helm chart package, upload it as an artifact, then publish it to a separate Helm package repository. - Adds manual dispatch support to publish a specific version.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if: | | ||
| github.event_name == 'workflow_dispatch' || | ||
| ( | ||
| github.event.workflow_run.conclusion == 'success' && | ||
| github.event.workflow_run.event == 'push' && | ||
| contains(github.event.workflow_run.head_branch, '.') | ||
| ) |
| - name: Normalize release version | ||
| id: version | ||
| run: | | ||
| set -eux | ||
|
|
||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| RAW="${{ github.event.inputs.version }}" | ||
| else | ||
| RAW="${{ github.event.workflow_run.head_branch }}" | ||
| fi | ||
|
|
||
| case "$RAW" in | ||
| refs/tags/*) | ||
| RAW_TAG="${RAW#refs/tags/}" | ||
| ;; | ||
| *) | ||
| RAW_TAG="$RAW" | ||
| ;; | ||
| esac |
| git config --global user.email "${{ secrets.EMAIL_ADDRESS }}" | ||
| git add . | ||
| git commit -m "Update rustfs helm package with ${{ needs.build-helm-package.outputs.app_version }}." || echo "No changes to commit" | ||
| git push origin main |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a956cf92e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| github.event_name == 'workflow_dispatch' || | ||
| ( | ||
| github.event.workflow_run.conclusion == 'success' && | ||
| github.event.workflow_run.event == 'push' && |
There was a problem hiding this comment.
Allow release workflow_run events to publish charts
The upstream .github/workflows/docker.yml workflow named Publish Docker Image is triggered by release and workflow_dispatch, not by push, so this condition filters out the successful Docker publish runs that should automatically publish the chart. In that release path, github.event.workflow_run.event is release, making build-helm-package skip entirely unless someone runs this workflow manually.
Useful? React with 👍 / 👎.
|
|
||
| outputs: | ||
| raw_tag: ${{ steps.version.outputs.raw_tag }} | ||
| chart_version: ${{ steps.version.outputs.chart_version }} |
There was a problem hiding this comment.
Set the chart_version output before using it
The Normalize release version step only assigns shell variables and never writes chart_version to $GITHUB_OUTPUT, so this job output resolves to an empty string on both manual and workflow_run executions. The later helm package --version "${{ steps.version.outputs.chart_version }}" then cannot package the requested release version.
Useful? React with 👍 / 👎.
| - name: Replace chart version and app version | ||
| run: | | ||
| set -eux | ||
| sed -i -E 's/^version:.*/version: "${{ steps.version.outputs.chart_version }}"/' helm/rustfs/Chart.yaml |
There was a problem hiding this comment.
Update the existing chart path before packaging
Repo-wide search shows the chart lives at deploy/rustfs-operator/Chart.yaml, which is also the path packaged below, but this command edits helm/rustfs/Chart.yaml. Any run that reaches this step fails immediately with a missing file instead of producing the Helm artifact.
Useful? React with 👍 / 👎.
|
|
||
| steps: | ||
| - name: Checkout helm chart repo | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
There was a problem hiding this comment.
Check out the Docker workflow's head SHA
For automatic workflow_run publishes, GitHub sets the follow-up workflow's GITHUB_SHA/GITHUB_REF to the default branch, and actions/checkout uses that triggering ref by default. That means a chart publish for an older release tag can package whatever is currently on main instead of the commit that the successful Docker workflow built, so the chart contents can drift from the released image unless this checkout pins github.event.workflow_run.head_sha or the release ref.
Useful? React with 👍 / 👎.
| helm package ./deploy/rustfs-operator \ | ||
| --destination deploy/rustfs-operator/ \ | ||
| --version "${{ steps.version.outputs.chart_version }}" |
There was a problem hiding this comment.
Override appVersion when packaging releases
This package command only overrides the chart version; it never sets appVersion, so each published archive keeps the checked-in appVersion: "0.1.0". The chart templates emit .Chart.AppVersion as app.kubernetes.io/version, so installing a 1.0.0 chart would still label its resources as 0.1.0 unless the workflow also passes the release version as the app version.
Useful? React with 👍 / 👎.
| helm package ./deploy/rustfs-operator \ | ||
| --destination deploy/rustfs-operator/ \ | ||
| --version "${{ steps.version.outputs.chart_version }}" |
There was a problem hiding this comment.
Pin the packaged chart to the released image tag
When users install one of these published chart versions without extra --set overrides, the packaged values.yaml still has operator.image.tag: latest, and the deployment template uses that value for the operator image. Since this workflow only changes the chart metadata before helm package, a versioned chart can deploy whatever latest points to instead of the Docker image version that just triggered the publish.
Useful? React with 👍 / 👎.
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Publish helm chart to artifacthub |
| - name: Replace chart version and app version | ||
| run: | | ||
| set -eux | ||
| sed -i -E 's/^version:.*/version: "${{ steps.version.outputs.chart_version }}"/' deploy/rustfs-operator/Chart.yaml | ||
|
|
| - name: Generate index | ||
| run: helm repo index . --url https://operator.rustfs.com | ||
|
|
| - name: Push helm package and index file | ||
| run: | | ||
| set -eux | ||
| git config --global user.name "${{ secrets.USERNAME }}" | ||
| git config --global user.email "${{ secrets.EMAIL_ADDRESS }}" |
| set -eux | ||
| git config --global user.name "${{ secrets.USERNAME }}" | ||
| git config --global user.email "${{ secrets.EMAIL_ADDRESS }}" | ||
| git add . |
Type of Change
Related Issues
Summary of Changes
Checklist
make pre-commit(fmt-check + clippy + test + console-lint + console-fmt-check)[Unreleased](if user-visible change)Impact
Verification
Additional Notes
Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.