|
| 1 | +name: Publish Helm Chart |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish-helm-chart: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout repository |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Set up Helm |
| 16 | + uses: azure/setup-helm@v4 |
| 17 | + |
| 18 | + - name: Package Helm Chart |
| 19 | + id: package |
| 20 | + run: | |
| 21 | + cd deploy/helm |
| 22 | + rm -f baserow/Chart.lock |
| 23 | +
|
| 24 | + # Add Helm repositories |
| 25 | + helm repo add bitnami https://charts.bitnami.com/bitnami |
| 26 | + helm repo add caddy https://caddyserver.github.io/ingress |
| 27 | +
|
| 28 | + # Build dependencies |
| 29 | + helm dependency build baserow |
| 30 | +
|
| 31 | + # Lint the chart with strict mode |
| 32 | + helm lint baserow --strict |
| 33 | +
|
| 34 | + # Package the chart |
| 35 | + helm package baserow |
| 36 | +
|
| 37 | + # Get chart details |
| 38 | + CHART_FILE=$(ls baserow-*.tgz) |
| 39 | + echo "chart-file=$CHART_FILE" >> $GITHUB_OUTPUT |
| 40 | +
|
| 41 | + HELM_CHART_VERSION=$(helm show chart baserow | grep '^version:' | awk '{print $2}') |
| 42 | + echo "chart-version=$HELM_CHART_VERSION" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + echo "Packaged chart: $CHART_FILE (version: $HELM_CHART_VERSION)" |
| 45 | +
|
| 46 | + - name: Upload Helm Chart Artifact |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: helm-chart |
| 50 | + path: deploy/helm/baserow-*.tgz |
| 51 | + retention-days: 30 |
| 52 | + |
| 53 | + - name: Generate GitHub App Token |
| 54 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 55 | + id: generate-token |
| 56 | + uses: actions/create-github-app-token@v2 |
| 57 | + with: |
| 58 | + app-id: ${{ vars.CHART_REPO_APP_ID }} |
| 59 | + private-key: ${{ secrets.CHART_REPO_APP_PRIVATE_KEY }} |
| 60 | + owner: ${{ vars.CHART_REPO_OWNER }} |
| 61 | + repositories: ${{ vars.CHART_REPO_NAME }} |
| 62 | + |
| 63 | + - name: Trigger Chart Repository Update |
| 64 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 65 | + run: | |
| 66 | + curl -X POST \ |
| 67 | + -H "Accept: application/vnd.github.v3+json" \ |
| 68 | + -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \ |
| 69 | + https://api.github.com/repos/${{ vars.CHART_REPO_OWNER }}/${{ vars.CHART_REPO_NAME }}/dispatches \ |
| 70 | + -d '{ |
| 71 | + "event_type": "helm-chart-published", |
| 72 | + "client_payload": { |
| 73 | + "chart_file": "${{ steps.package.outputs.chart-file }}", |
| 74 | + "chart_version": "${{ steps.package.outputs.chart-version }}", |
| 75 | + "app_version": "${{ github.ref_name }}", |
| 76 | + "source_repo": "${{ github.event.repository.name }}", |
| 77 | + "source_run_id": "${{ github.run_id }}" |
| 78 | + } |
| 79 | + }' |
0 commit comments