Skip to content

Comments

Create workflow to publish helm chart#119

Merged
esune merged 3 commits intomainfrom
i5okie/chart-release-workflow
Aug 15, 2025
Merged

Create workflow to publish helm chart#119
esune merged 3 commits intomainfrom
i5okie/chart-release-workflow

Conversation

@i5okie
Copy link
Contributor

@i5okie i5okie commented Aug 13, 2025

  • Added chart_releaser action
  • Added chart_release workflow
  • Created gh-pages branch with an empty index.yaml

i5okie added 2 commits August 13, 2025 12:38
Signed-off-by: Ivan P <2119240+i5okie@users.noreply.github.com>
Signed-off-by: Ivan P <2119240+i5okie@users.noreply.github.com>
Comment on lines 13 to 29
name: Validate Chart Index
runs-on: ubuntu-latest
if: github.repository_owner == 'bcgov'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Download remote index file and check equality
run: |
curl -vsSL https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/index.yaml > index.yaml.remote
LOCAL="$(md5sum < index.yaml)"
REMOTE="$(md5sum < index.yaml.remote)"
echo "$LOCAL" = "$REMOTE"
test "$LOCAL" = "$REMOTE"

chart-release:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 6 months ago

To fix the problem, add a permissions block to the workflow or to each job, specifying the minimal required permissions. Since the validate-chart-index job only checks out code and downloads files, it only needs contents: read. The chart-release job may require contents: write if it pushes changes or creates releases, but as a minimal starting point, we can set contents: read and escalate only if necessary. The best practice is to add the permissions block at the workflow root so it applies to all jobs, unless a job needs different permissions. This change should be made at the top level of .github/workflows/chart_release.yaml, after the name field and before on:.

Suggested changeset 1
.github/workflows/chart_release.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/chart_release.yaml b/.github/workflows/chart_release.yaml
--- a/.github/workflows/chart_release.yaml
+++ b/.github/workflows/chart_release.yaml
@@ -1,3 +1,5 @@
+permissions:
+  contents: read
 name: Helm Chart Release
 
 on:
EOF
@@ -1,3 +1,5 @@
permissions:
contents: read
name: Helm Chart Release

on:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Comment on lines 30 to 49
name: Create and Publish Chart Release
runs-on: ubuntu-latest
if: github.repository_owner == 'bcgov'
needs: [ validate-chart-index ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4
- name: Release workload charts
uses: ./.github/actions/chart_releaser
with:
config: .github/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 6 months ago

To fix the problem, you should add a permissions block to the workflow, specifying the minimal required permissions for the jobs. Since the workflow contains two jobs (validate-chart-index and chart-release), and the main concern is the use of the GITHUB_TOKEN (especially in the chart-release job), you should set contents: read at the workflow level as a minimal starting point. If the jobs require additional permissions (such as contents: write or packages: write), you can add those as needed, but the minimal fix is to add permissions: contents: read at the top level of the workflow. This change should be made near the top of the file, after the name and before the on block.

Suggested changeset 1
.github/workflows/chart_release.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/chart_release.yaml b/.github/workflows/chart_release.yaml
--- a/.github/workflows/chart_release.yaml
+++ b/.github/workflows/chart_release.yaml
@@ -1,5 +1,8 @@
 name: Helm Chart Release
 
+permissions:
+  contents: read
+
 on:
   push:
     tags:
EOF
@@ -1,5 +1,8 @@
name: Helm Chart Release

permissions:
contents: read

on:
push:
tags:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Signed-off-by: Ivan P <2119240+i5okie@users.noreply.github.com>
Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@esune esune merged commit ac112ab into main Aug 15, 2025
6 checks passed
@esune esune deleted the i5okie/chart-release-workflow branch August 15, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants