Skip to content

Chore: Updated the GitHub Actions for main branch #1

Chore: Updated the GitHub Actions for main branch

Chore: Updated the GitHub Actions for main branch #1

Workflow file for this run

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
- name: Preserve build output when moving branches
# If this is not done then the build folder will be lost when we switch branches
run: mv dist/csss-ng-frontend/browser ../build-tmp
- name: Switch to the build branch and clean it
run: |
# Get the latest on the branch that builds are held in and switch to it
git fetch origin build
git switch build
# Remove everything in order to copy everything over
rm -rf *
- name: Copy the built files over to the root directory and push to `build`
run: |
cp -R ../build-tmp/* .
- name: Commit and push
run: |
# Set up a dummy user and email for identification purposes
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@user.noreply.github.com"
git add .
git commit -m "${{ github.event.pull_request.title }}"
git push origin build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}