From 8add75e1adb8939163dd990a140c611b5743d3a7 Mon Sep 17 00:00:00 2001 From: browol Date: Sun, 26 Nov 2023 14:55:58 +0700 Subject: [PATCH] feat(cd): added chart release workflow --- .github/workflows/configs/cr.yaml | 6 ++ .../{lint-test.yaml => lint-test.yml} | 0 .github/workflows/release.yml | 62 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .github/workflows/configs/cr.yaml rename .github/workflows/{lint-test.yaml => lint-test.yml} (100%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/configs/cr.yaml b/.github/workflows/configs/cr.yaml new file mode 100644 index 0000000..b313f36 --- /dev/null +++ b/.github/workflows/configs/cr.yaml @@ -0,0 +1,6 @@ +## Reference: https://github.com/helm/chart-releaser +index-path: "./index.yaml" + +# 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 \ No newline at end of file diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yml similarity index 100% rename from .github/workflows/lint-test.yaml rename to .github/workflows/lint-test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f9f7a8d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +## Reference: https://github.com/helm/chart-releaser-action +name: Chart Publish +on: + push: + branches: + - main + paths: + - "charts/**" + +permissions: + contents: read + +jobs: + publish: + permissions: + contents: write # for helm/chart-releaser-action to push chart release and create a release + packages: write # to push OCI chart package to GitHub Registry + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 + with: + version: v3.10.1 # Also update in lint-and-test.yaml + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + ## This is required to consider the old Circle-CI Index and to stay compatible with all the old releases. + - name: Fetch current Chart Index + run: | + git checkout origin/gh-pages index.yaml + + - name: Run chart-releaser + uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0 + with: + config: "./.github/configs/cr.yaml" + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Login to GHCR + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push chart to GHCR + run: | + 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 }} + done \ No newline at end of file