chore: fix release when no artifacts (#138) #145
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Charts | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish-gh-pages: | |
name: Publish to Github pages | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
outputs: | |
has_artifacts: ${{ steps.check-artifacts.outputs.has_artifacts }} | |
steps: | |
- name: Checkout | |
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: Run chart-releaser | |
uses: helm/chart-releaser-action@v1.6.0 | |
with: | |
config: "./cr.yaml" | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Check if artifacts exist | |
id: check-artifacts | |
run: | | |
if ls .cr-release-packages/* >/dev/null 2>&1; then | |
echo "has_artifacts=true" >> $GITHUB_OUTPUT | |
else | |
echo "has_artifacts=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
if: steps.check-artifacts.outputs.has_artifacts == 'true' | |
with: | |
name: artifacts | |
path: .cr-release-packages/ | |
publish-oci: | |
name: Publish to ghcr.io | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write # needed for pushing to github registry | |
id-token: write # needed for signing the images with GitHub OIDC Token | |
needs: [publish-gh-pages] | |
if: needs.publish-gh-pages.outputs.has_artifacts == 'true' | |
steps: | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@v3 | |
- name: Downloads artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: .cr-release-packages/ | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push charts to GHCR | |
env: | |
COSIGN_YES: true | |
run: | | |
for chart in `find .cr-release-packages -name '*.tgz' -print`; do | |
helm push ${chart} oci://ghcr.io/${GITHUB_REPOSITORY} |& tee helm-push-output.log | |
file_name=${chart##*/} | |
chart_name=${file_name%-*} | |
digest=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log) | |
cosign sign "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}@${digest}" | |
done |