-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: helm chart deploy to open PRs to now-protected gh-pages branch #31155
Changes from all commits
a2ae36e
34a89c0
283150d
4f70aba
7a837de
a34151f
0b3276f
57e0625
db96032
0d363b4
bfba035
edbcdfe
4ff6d50
ad4e20b
ae5a177
c8ac72a
e3a0832
a4dfaf1
02a484d
81faf33
02d86cc
89bb6ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+26 −0 | .github/dependabot.yml | |
+63 −0 | .github/workflows/test-action.yml | |
+56 −16 | README.md | |
+91 −6 | action.yml | |
+265 −185 | cr.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Lint and Test Charts | ||
name: "Helm: lint and test charts" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice improvement... I'll bet half the people that see this think it's eslint and dataviz charts :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's been bugging me for a moment. Making the repo a better place, one line at a time. |
||
on: | ||
pull_request: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably expand the code owners for these reviews... maybe you want to be one? |
||
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 }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh... don't think I've seen it show this before. Neat!