Update chart publishing workflow #3
Workflow file for this run
This file contains hidden or 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 Helm Charts | |
| on: | |
| release: | |
| types: | |
| - published | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'charts/gardener-extension-provider-ironcore/**' | |
| - 'charts/gardener-extension-admission-ironcore/**' | |
| tags: | |
| - 'v*.*.*' | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - 'docs/**' | |
| - '**/*.md' | |
| types: [labeled, opened, synchronize, reopened] | |
| workflow_dispatch: | |
| jobs: | |
| helm-chart: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| if: | | |
| github.event_name == 'push' || | |
| (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts')) || | |
| (github.event_name == 'release' && github.event.action == 'published') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: v3.16.2 | |
| - name: Determine chart version | |
| id: chart_version | |
| run: | | |
| if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| # Use SHA for main branch | |
| CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)" | |
| elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| # Use tag version (strip 'v' prefix) | |
| CHART_VERSION="${GITHUB_REF#refs/tags/v}" | |
| else | |
| # Use PR SHA for dry run | |
| CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)" | |
| fi | |
| echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT | |
| - name: Log in to GitHub Container Registry | |
| run: | | |
| echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Package Helm charts | |
| run: | | |
| helm package charts/gardener-extension-provider-ironcore --version ${{ steps.chart_version.outputs.version }} | |
| helm package charts/gardener-extension-admission-ironcore --version ${{ steps.chart_version.outputs.version }} | |
| - name: Push Helm charts to GHCR | |
| run: | | |
| helm push gardener-extension-provider-ironcore-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts | |
| helm push gardener-extension-admission-ironcore-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts |