Skip to content

Commit

Permalink
new way to publish new helm chart versions
Browse files Browse the repository at this point in the history
  • Loading branch information
edevosc2c committed Nov 8, 2024
1 parent c81387a commit 6858aef
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 32 deletions.
53 changes: 21 additions & 32 deletions .github/workflows/helm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Helm publish on new commit and new version
name: Helm publish new version

on:
push:
branches:
- 'main'
- '!gh-pages'

jobs:
chart-publish:
Expand All @@ -20,43 +19,33 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Helm Installation
uses: azure/setup-helm@v3
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.12.0

- name: Run chart-releaser for publish on new version
if: github.ref == 'refs/heads/main'
uses: helm/chart-releaser-action@main
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: '.'
charts_dir: .
config: cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: "true"

- name: Checkout gh-pages branch
uses: actions/checkout@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
fetch-depth: 0
ref: 'gh-pages'
path: gh-pages
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Helm Package all the charts using commit ID and remove chart packages older than 6 months
shell: bash
- name: Push charts to GHCR
run: |
mv gh-pages /tmp/gh-pages
for directory in *; do
if [ -d "$directory" ]; then
helm package "$directory" -d /tmp/gh-pages --version $(helm show chart "$directory" |grep ^version: | awk '{print $2}')-"$GITHUB_REF_NAME"-"${GITHUB_SHA::7}"
shopt -s nullglob
for pkg in .cr-release-packages/*.tgz; do
if [ -z "${pkg:-}" ]; then
break
fi
helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts"
done
cd /tmp/gh-pages
find . -type f -mtime +180 -delete
helm repo index . --merge index.yaml
cd $GITHUB_WORKSPACE
mv /tmp/gh-pages .
- name: Deploy to GitHub Pages the charts based on the commit ID
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# WARNING: New location storage for the helm chart

All the helm chart are now stored inside the GitHub Docker registry.

Please use it like so:

## For helmfile.yaml

```
chart: oci://ghcr.io/camptocamp/charts-gs/myhelmchart
version: X.X.X
```

You don't need to include this anymore:
```
repositories:
- name: charts-gs
url: https://camptocamp.github.io/charts-gs/
```

Make sure to migrate to this new way of working.

## When installing manually

```
helm install myapp oci://ghcr.io/camptocamp/charts-gs/myhelmchart --version X.X.X
```
5 changes: 5 additions & 0 deletions cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sign: false

# Enable automatic generation of release notes using GitHubs release notes generator.
# see: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
generate-release-notes: true

0 comments on commit 6858aef

Please sign in to comment.