fix: helm chart deploy to open PRs to now-protected gh-pages branch (#31155)
This commit is contained in:
parent
73164c61ad
commit
97683ec052
|
|
@ -1 +1 @@
|
||||||
Subproject commit 120944e66390c2534cc1b3c62d7285ba7ff02594
|
Subproject commit a917fd15b20e8b64b94d9158ad54cd6345335584
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
name: Lint and Test Charts
|
name: "Helm: lint and test charts"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
|
||||||
|
|
@ -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:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -7,18 +11,28 @@ on:
|
||||||
- "[0-9].[0-9]*"
|
- "[0-9].[0-9]*"
|
||||||
paths:
|
paths:
|
||||||
- "helm/**"
|
- "helm/**"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
description: "The branch, tag, or commit SHA to check out"
|
||||||
|
required: false
|
||||||
|
default: "master"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
ref: ${{ inputs.ref || github.ref_name }}
|
||||||
|
persist-credentials: true
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|
@ -35,11 +49,77 @@ jobs:
|
||||||
- name: Add bitnami repo dependency
|
- name: Add bitnami repo dependency
|
||||||
run: helm repo add bitnami https://charts.bitnami.com/bitnami
|
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
|
- name: Run chart-releaser
|
||||||
uses: ./.github/actions/chart-releaser-action
|
uses: ./.github/actions/chart-releaser-action
|
||||||
with:
|
with:
|
||||||
|
version: v1.6.0
|
||||||
charts_dir: helm
|
charts_dir: helm
|
||||||
mark_as_latest: false
|
mark_as_latest: false
|
||||||
|
pages_branch: ${{ env.branch_name }}
|
||||||
env:
|
env:
|
||||||
CR_TOKEN: "${{ github.token }}"
|
CR_TOKEN: "${{ github.token }}"
|
||||||
CR_RELEASE_NAME_TEMPLATE: "superset-helm-chart-{{ .Version }}"
|
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 }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue