1.0.3 #102
Workflow file for this run
This file contains 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
# 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') | |
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=$([[ "$(git branch --show-current)" == "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 | |
[[ "${{ env.BRANCH }}" != "dist" ]] && 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 |