Syntax fix was not being applied to main, so repulling #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Builds and pushes the results to the `build` branch when a pull request is merged into `main` | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
jobs: | |
deploy-to-branch: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout `main` | |
uses: actions/checkout@v4 | |
- name: Set up Node.js, install dependencies and build | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.x' | |
- run: npm ci | |
- run: npm run build --if-present | |
- name: Preserve build output when moving branches | |
run: mv build ../build-tmp | |
- name: Switch to the build branch and clean it | |
run: | | |
# Based off the script `./scripts/deploy_to_branch.sh` | |
# The branch we are publishing to | |
git fetch origin build | |
git switch build | |
rm -rf * | |
- name: Copy the built files over to the root directory and push to `build` | |
run: | | |
# Set up a dummy user and email for identification purposes | |
cp -R ../build-tmp/* . | |
rm -f ./js/*.LICENSE.txt | |
- name: Commit and push | |
run: | | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "${{ github.actor }}@user.noreply.github.com" | |
git add . | |
git commit -m "Updating `build` with PR#${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" | |
git push origin build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |