|
| 1 | +## Reference: https://github.com/helm/chart-releaser-action |
| 2 | +name: Chart Publish |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - codefresh-main |
| 7 | + paths: |
| 8 | + - "script/helm/garage/**" |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + permissions: |
| 16 | + contents: write # for helm/chart-releaser-action to push chart release and create a release |
| 17 | + packages: write # to push OCI chart package to GitHub Registry |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Install Helm |
| 26 | + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 |
| 27 | + with: |
| 28 | + version: v3.10.1 # Also update in lint-and-test.yaml |
| 29 | + |
| 30 | + - name: Configure Git |
| 31 | + run: | |
| 32 | + git config user.name "$GITHUB_ACTOR" |
| 33 | + git config user.email "[email protected]" |
| 34 | +
|
| 35 | + - name: Package chart |
| 36 | + run: | |
| 37 | + rm -rf .cr-release-packages |
| 38 | + mkdir .cr-release-packages |
| 39 | + helm package script/helm/garage -u -d .cr-release-packages/ |
| 40 | +
|
| 41 | + # The GitHub repository secret `PGP_PRIVATE_KEY` contains the private key |
| 42 | + # in ASCII-armored format. To export a (new) key, run this command: |
| 43 | + # `gpg --armor --export-secret-key <my key>` |
| 44 | + - name: Prepare PGP key |
| 45 | + run: | |
| 46 | + IFS="" |
| 47 | + echo "$PGP_PRIVATE_KEY" | gpg --dearmor > $HOME/secring.gpg |
| 48 | + echo "$PGP_PASSPHRASE" > $HOME/passphrase.txt |
| 49 | +
|
| 50 | + # Tell chart-releaser-action where to find the key and its passphrase |
| 51 | + echo "CR_KEYRING=$HOME/secring.gpg" >> "$GITHUB_ENV" |
| 52 | + echo "CR_PASSPHRASE_FILE=$HOME/passphrase.txt" >> "$GITHUB_ENV" |
| 53 | + env: |
| 54 | + PGP_PRIVATE_KEY: "${{ secrets.PGP_PRIVATE_KEY }}" |
| 55 | + PGP_PASSPHRASE: "${{ secrets.PGP_PASSPHRASE }}" |
| 56 | + |
| 57 | + - name: Run chart-releaser |
| 58 | + uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.5.0 - currently there is a bug on 1.6.0 version, can upgrade back when it'll be solved - https://github.com/helm/chart-releaser-action/issues/171 |
| 59 | + with: |
| 60 | + config: "./.github/configs/cr.yaml" |
| 61 | + skip_packaging: true |
| 62 | + charts_dir: script/helm |
| 63 | + env: |
| 64 | + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 65 | + |
| 66 | + - name: Login to GHCR |
| 67 | + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 |
| 68 | + with: |
| 69 | + registry: ghcr.io |
| 70 | + username: ${{ github.actor }} |
| 71 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Push chart to GHCR |
| 74 | + run: | |
| 75 | + shopt -s nullglob |
| 76 | + for pkg in .cr-release-packages/*.tgz; do |
| 77 | + if [ -z "${pkg:-}" ]; then |
| 78 | + break |
| 79 | + fi |
| 80 | + helm push "${pkg}" oci://ghcr.io/${{ github.repository }} |
| 81 | + done |
0 commit comments