You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2024/11/26 02:38:18 UTC

(superset) branch master updated: fix: helm chart deploy to open PRs to now-protected gh-pages branch (#31155)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 97683ec052 fix: helm chart deploy to open PRs to now-protected gh-pages branch (#31155)
97683ec052 is described below

commit 97683ec05297fc6eeffde08b02063aaa8223eff3
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Nov 25 18:38:12 2024 -0800

    fix: helm chart deploy to open PRs to now-protected gh-pages branch (#31155)
---
 .github/actions/chart-releaser-action       |  2 +-
 .github/workflows/superset-helm-lint.yml    |  2 +-
 .github/workflows/superset-helm-release.yml | 86 ++++++++++++++++++++++++++++-
 3 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/.github/actions/chart-releaser-action b/.github/actions/chart-releaser-action
index 120944e663..a917fd15b2 160000
--- a/.github/actions/chart-releaser-action
+++ b/.github/actions/chart-releaser-action
@@ -1 +1 @@
-Subproject commit 120944e66390c2534cc1b3c62d7285ba7ff02594
+Subproject commit a917fd15b20e8b64b94d9158ad54cd6345335584
diff --git a/.github/workflows/superset-helm-lint.yml b/.github/workflows/superset-helm-lint.yml
index 5649f491a4..36ef523fe4 100644
--- a/.github/workflows/superset-helm-lint.yml
+++ b/.github/workflows/superset-helm-lint.yml
@@ -1,4 +1,4 @@
-name: Lint and Test Charts
+name: "Helm: lint and test charts"
 
 on:
   pull_request:
diff --git a/.github/workflows/superset-helm-release.yml b/.github/workflows/superset-helm-release.yml
index 24486e14b6..abb25886d7 100644
--- a/.github/workflows/superset-helm-release.yml
+++ b/.github/workflows/superset-helm-release.yml
@@ -1,4 +1,8 @@
-name: Release Charts
+# This workflow automates the release process for Helm charts.
+# The workflow creates a new branch for the release and opens a pull request against the 'gh-pages' branch,
+# allowing the changes to be reviewed and merged manually.
+
+name: "Helm: release charts"
 
 on:
   push:
@@ -7,18 +11,28 @@ on:
       - "[0-9].[0-9]*"
     paths:
       - "helm/**"
+  workflow_dispatch:
+    inputs:
+      ref:
+        description: "The branch, tag, or commit SHA to check out"
+        required: false
+        default: "master"
 
 jobs:
   release:
     runs-on: ubuntu-22.04
     permissions:
       contents: write
+      pull-requests: write
+    env:
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
     steps:
-      - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
+      - name: Checkout code
         uses: actions/checkout@v4
         with:
-          persist-credentials: false
+          ref: ${{ inputs.ref || github.ref_name }}
+          persist-credentials: true
           submodules: recursive
           fetch-depth: 0
 
@@ -35,11 +49,77 @@ jobs:
       - name: Add bitnami repo dependency
         run: helm repo add bitnami https://charts.bitnami.com/bitnami
 
+      - name: Fetch/list all tags
+        run: |
+          # Debugging tags
+          git fetch --tags --force
+          git tag -d superset-helm-chart-0.13.4 || true
+          echo "DEBUG TAGS"
+          git show-ref --tags
+
+      - name: Create unique pages branch name
+        id: vars
+        run: echo "branch_name=helm-publish-${GITHUB_SHA:0:7}" >> $GITHUB_ENV
+
+      - name: Force recreate branch from gh-pages
+        run: |
+          # Ensure a clean working directory
+          git reset --hard
+          git clean -fdx
+          git checkout -b local_gha_temp
+          git submodule update
+
+          # Fetch the latest gh-pages branch
+          git fetch origin gh-pages
+
+          # Check out and reset the target branch based on gh-pages
+          git checkout -B ${{ env.branch_name }} origin/gh-pages
+
+          # Remove submodules from the branch
+          git submodule deinit -f --all
+
+          # Force push to the remote branch
+          git push origin ${{ env.branch_name }} --force
+
+          # Return to the original branch
+          git checkout local_gha_temp
+
+      - name: Fetch/list all tags
+        run: |
+          git submodule update
+          cat .github/actions/chart-releaser-action/action.yml
+
       - name: Run chart-releaser
         uses: ./.github/actions/chart-releaser-action
         with:
+          version: v1.6.0
           charts_dir: helm
           mark_as_latest: false
+          pages_branch: ${{ env.branch_name }}
         env:
           CR_TOKEN: "${{ github.token }}"
           CR_RELEASE_NAME_TEMPLATE: "superset-helm-chart-{{ .Version }}"
+
+      - name: Open Pull Request
+        uses: actions/github-script@v7
+        with:
+          script: |
+            const branchName = '${{ env.branch_name }}';
+            const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
+
+            if (!branchName) {
+              throw new Error("Branch name is not defined.");
+            }
+
+            const pr = await github.rest.pulls.create({
+              owner,
+              repo,
+              title: `Helm chart release for ${branchName}`,
+              head: branchName,
+              base: "gh-pages", // Adjust if the target branch is different
+              body: `This PR releases Helm charts to the gh-pages branch.`,
+            });
+
+            core.info(`Pull request created: ${pr.data.html_url}`);
+        env:
+          BRANCH_NAME: ${{ env.branch_name }}