Skip to content

1.0.4

1.0.4 #125

Workflow file for this run

# The site is built on branch `dist`, in folder `docs`,
# which makes the build compatible with Github Pages and Netlify
name: Build website
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
branches:
- "staging**"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: "build-website"
cancel-in-progress: true
jobs:
build-website:
# Note: `github.event.base_ref` is equal to `refs/heads/main` only when the workflow is triggered
# by a lightweight tag (_not_ an annotated tag) placed on the last commit of the `main` branch
if: github.event.base_ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/staging') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "nvmrc=$(cat .nvmrc)" >> $GITHUB_ENV
id: nvmrc
- uses: actions/setup-node@v4
with:
node-version: "${{ env.nvmrc }}"
cache: npm
- run: npm ci
- run: echo "APP_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
id: APP_VERSION
- run: echo "BRANCH=$(${{ github.event.base_ref == 'refs/heads/main' || github.ref == 'refs/heads/main' }} && echo "dist" || echo "staging/dist")" >> $GITHUB_ENV
id: BRANCH
- run: echo "SENTRY_ENVIRONMENT=$([[ "${{ env.BRANCH }}" == "dist" ]] && echo "production" || echo "staging")" >> $GITHUB_ENV
id: SENTRY_ENVIRONMENT
- env:
DOMAIN: "${{ secrets.DOMAIN }}"
run: sed -i "s/\$DOMAIN/${{ env.DOMAIN }}/" index.html
- env:
ENVIRONMENT: "${{ env.SENTRY_ENVIRONMENT }}"
APP_VERSION: "${{ env.APP_VERSION }}"
DOMAIN: "${{ secrets.DOMAIN }}"
SENTRY_INGEST: "${{ secrets.SENTRY_INGEST }}"
PLAUSIBLE_API_URL: "${{ secrets.PLAUSIBLE_API_URL }}"
PB_INSTANCES: "${{ secrets.PB_INSTANCES }}"
run: npm run build
- run: |
git checkout index.html
[[ "$(git branch --show-current)" != "main" ]] && git fetch && git branch main remotes/origin/main
git switch --orphan ${{ env.BRANCH }}
git checkout main netlify.toml
git add docs
git config user.name "Zwyx - GitHub Actions"
git config user.email "29386932+Zwyx@users.noreply.github.com>"
git commit -m "Build website"
git push --set-upstream origin --force ${{ env.BRANCH }}
#
# - name: Setup tmate session
# if: ${{ always() }}
# timeout-minutes: 30 # Run `sudo shutdown -h now` to terminate the session
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# uses: mxschmitt/action-tmate@v3