diff --git a/.github/workflows/helm-oci.yaml b/.github/workflows/helm-oci.yaml new file mode 100644 index 0000000..eb34924 --- /dev/null +++ b/.github/workflows/helm-oci.yaml @@ -0,0 +1,77 @@ +name: Release Helm Charts + +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' + +jobs: + release: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Helm + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 + with: + version: v3.12.0 + + - name: Set chart name + id: chart-name + run: echo "value=${{ github.event.repository.name }}" >> "$GITHUB_OUTPUT" + + - name: Set OCI registry name + id: oci-registry-name + run: echo "value=ghcr.io/${{ github.repository_owner }}/helm-charts" >> "$GITHUB_OUTPUT" + + - name: Set OCI chart name + id: oci-chart-name + run: echo "value=${{ steps.oci-registry-name.outputs.value }}/${{ steps.chart-name.outputs.value }}" >> "$GITHUB_OUTPUT" + + - name: Helm lint + run: helm lint charts/${{ steps.chart-name.outputs.value }} + + - name: Determine raw version + uses: haya14busa/action-cond@1d6e8a12b20cdb4f1954feef9aa475b9c390cab5 # v1.1.1 + id: raw-version + with: + cond: ${{ github.ref_type == 'tag' }} + if_true: ${{ github.ref_name }} + if_false: v0.0.0 + + - name: Determine version + id: version + run: | + VERSION=${{ steps.raw-version.outputs.value }} + echo "value=${VERSION#v}" >> "$GITHUB_OUTPUT" + + - name: Helm package + id: build + run: | + helm package charts/${{ steps.chart-name.outputs.value }} --version ${{ steps.version.outputs.value }} --app-version ${{ steps.raw-version.outputs.value }} + echo "package=${{ steps.chart-name.outputs.value }}-${{ steps.version.outputs.value }}.tgz" >> "$GITHUB_OUTPUT" + + - name: Login to GitHub Container Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + if: github.ref_type == 'tag' + + - name: Helm push + run: helm push ${{ steps.build.outputs.package }} oci://${{ steps.oci-registry-name.outputs.value }} + env: + HELM_REGISTRY_CONFIG: ~/.docker/config.json + if: github.ref_type == 'tag'