Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the release workflow by moving the Helm chart release action from an external repository reference to a local composite action within the repository. The change improves maintainability by consolidating workflow logic and updates the authentication token used for GitOps operations.
- Introduces a new local composite action for releasing Helm charts
- Updates the production CD workflow to use the local action instead of external reference
- Changes the authentication token from INTERNAL_ACCESS_TOKEN to GITOPS_TOKEN
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| .github/workflows/release-chart/action.yaml | New composite action that packages and publishes Helm charts to the moreh-dev/helm-charts repository |
| .github/workflows/cd-prod.yaml | Updates the release step to use the local action and updates the GitHub token secret name |
| sed -i "s/^version:.*/version: \"${{ inputs.chart_version }}\"/g" ${{ inputs.chart_path }}/Chart.yaml | ||
| sed -i "s/^appVersion:.*/appVersion: \"${{ inputs.chart_version }}\"/g" ${{ inputs.chart_path }}/Chart.yaml | ||
|
|
||
| helm package ${{ inputs.chart_path }} |
There was a problem hiding this comment.
The sed commands use in-place editing with the -i flag, which modifies the Chart.yaml file in the checked-out source repository. However, this modification happens before packaging, and the changes are not committed to the source repository - only the packaged chart is pushed to helm-charts. This could lead to inconsistency where the Chart.yaml in the source repository doesn't match the packaged chart version. Consider whether the Chart.yaml should be updated in the source repository as well, or if the version should already be set correctly before this action runs.
| sed -i "s/^version:.*/version: \"${{ inputs.chart_version }}\"/g" ${{ inputs.chart_path }}/Chart.yaml | |
| sed -i "s/^appVersion:.*/appVersion: \"${{ inputs.chart_version }}\"/g" ${{ inputs.chart_path }}/Chart.yaml | |
| helm package ${{ inputs.chart_path }} | |
| helm package \ | |
| --version "${{ inputs.chart_version }}" \ | |
| --app-version "${{ inputs.chart_version }}" \ | |
| ${{ inputs.chart_path }} |
| @@ -0,0 +1,62 @@ | |||
| name: "Release Helm Chart" | |||
| description: "Release Helm Chart " | |||
There was a problem hiding this comment.
There is a trailing space after "Release Helm Chart" in the description. This should be removed for consistency.
| description: "Release Helm Chart " | |
| description: "Release Helm Chart" |
| description: "The version of application. It should be a semantic version" | ||
| github_token: | ||
| required: true | ||
| description: "Github repo access internal token" |
There was a problem hiding this comment.
The GitHub branding should use "GitHub" with capital "H" instead of "Github". This is the correct capitalization for the brand name.
| description: "Github repo access internal token" | |
| description: "GitHub repo access internal token" |
| git add . | ||
| git config --global user.name "${{ github.event.head_commit.author.name }}" | ||
| git config --global user.email "${{ github.event.head_commit.author.email }}" | ||
| git commit -m "feat: add ${{ inputs.chart_name }} ${{ inputs.chart_version }}" |
There was a problem hiding this comment.
The git commit step does not handle the case where there are no changes to commit. If the chart version already exists or no files were modified, the git commit command will fail and cause the workflow to fail. Consider adding a check to verify if there are changes before committing, or use a flag like --allow-empty or check git status first.
| git commit -m "feat: add ${{ inputs.chart_name }} ${{ inputs.chart_version }}" | |
| if ! git diff --cached --quiet; then | |
| git commit -m "feat: add ${{ inputs.chart_name }} ${{ inputs.chart_version }}" | |
| else | |
| echo "No changes to commit" | |
| fi |
| git config --global user.name "${{ github.event.head_commit.author.name }}" | ||
| git config --global user.email "${{ github.event.head_commit.author.email }}" |
There was a problem hiding this comment.
Using github.event.head_commit.author.name and github.event.head_commit.author.email may not be available in all GitHub event contexts (e.g., workflow_dispatch, pull_request events). This could cause the git config commands to set empty values, leading to commit failures. Consider using a fallback value or a more reliable context variable like github.actor.
| git config --global user.name "${{ github.event.head_commit.author.name }}" | |
| git config --global user.email "${{ github.event.head_commit.author.email }}" | |
| git config --global user.name "${{ github.event.head_commit.author.name || github.actor }}" | |
| git config --global user.email "${{ github.event.head_commit.author.email || format('{0}@users.noreply.github.com', github.actor) }}" |
No description provided.