Skip to content
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

Action allowing us to publish backported changes #130

Merged
merged 9 commits into from
Dec 12, 2023
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/publish-gh-pages-backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Backport GitHub Pages
# This workflow can be used to backport a release from a tag to the gh-pages branch
# This is useful when you want to backport a release to the gh-pages branch
# Most likely you will want to check and update BASE_REF and VERSIONS env variables
# @BASE_REF: the tag you want to backport from
# @VERSIONS: the versions you want to backport to

on:
workflow_dispatch:

env:
BASE_REF: v2.0.1-from-tag
VERSIONS: v1.0.0,v1.1.0,v1.2.1,v1.2.2,v2.0.0,v2.0.1,v2.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we hardcode this to prevent others from using it incorrectly and requiring a review for each change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, also not using inputs as they can have mistakes and are harder to check

jobs:
publish-to-gh-pages:
name: Publish to GitHub Pages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ env.BASE_REF }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install npm dependencies
run: yarn --immutable
- name: Run build script
run: |
yarn build:prod

- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: 'gh-pages'
path: 'gh-pages'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than checking out this branch as a sub path, have you considered using the same github-actions deploy action we use elsewhere?

uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305

We can use a matrix to iterate over each version target as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried this first but actions were failing when it ran them, will revisit this later tough as it is more elegant solution


- name: prep for pr
run: |
IFS=',' read -ra VERSION_ARRAY <<< ${{ env.VERSIONS }}
for version in "${VERSION_ARRAY[@]}"; do
rm -rf "gh-pages/${version}"/*
cp -r dist/* "gh-pages/${version}/"
done

- name: Commit files
run: |
cd gh-pages
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git status
git remote --verbose
git branch -D gh-pages-backport || true
git checkout -b gh-pages-backport
git add .
git commit -m "Update gh-pages"
git push origin gh-pages-backport -f
echo "Pushed build changes to gh-pages-backport"
echo "REMEMBER TO CREATE A PR FROM gh-pages-backport TO gh-pages"