Files
breeze/.gitea/workflows/pages.yml
T
waozi 3528bc94ce Use Build runners for Breeze workflows
[skip ci] A workflow-only change does not need a new Pages deployment.
2026-11-20 16:36:57 -03:00

157 lines
6.1 KiB
YAML

name: Cloudflare Pages
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
concurrency:
group: breeze-pages-${{ gitea.ref }}
cancel-in-progress: false
jobs:
site:
name: Build and verify the site
if: gitea.event_name == 'pull_request' || gitea.ref == 'refs/heads/master'
# Keep deployments on the same Build slot as its web artifact cache.
runs-on: build-breeze
timeout-minutes: 45
env:
SITE_ASSET_VERSION: ${{ gitea.sha }}
steps:
- name: Check out Breeze from Gitea
uses: https://github.com/actions/checkout@v4
env:
GIT_LFS_SKIP_SMUDGE: '1'
with:
persist-credentials: false
- name: Fetch the website's audio from Gitea LFS
run: sh site/fetch-meditation-audio.sh
- name: Set up Node.js
uses: https://github.com/actions/setup-node@v4
with:
node-version: 22
- name: Identify exact web build inputs
id: web-inputs
run: |
key=$(sh site/web-build-key.sh)
printf 'key=%s\n' "$key" >> "$GITHUB_OUTPUT"
- name: Restore the source-built web app
id: web-restore
uses: https://github.com/actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830
continue-on-error: true
with:
path: build/dist/web
key: breeze-web-${{ runner.os }}-${{ runner.arch }}-${{ steps.web-inputs.outputs.key }}
- name: Check the cached web build
id: web-cache
env:
WEB_INPUT_KEY: ${{ steps.web-inputs.outputs.key }}
run: |
if sh site/web-build-receipt.sh verify build/dist/web "$WEB_INPUT_KEY" 2>/dev/null; then
echo 'Reusing the verified web build for these inputs'
echo 'ready=true' >> "$GITHUB_OUTPUT"
else
echo 'Building the web app for these inputs'
echo 'ready=false' >> "$GITHUB_OUTPUT"
fi
- name: Install site build dependencies
run: USER="$(id -un)" .github/scripts/install-apt-packages.sh .github/apt/empty-packages.txt apt-utils gnupg ripgrep unzip zip zstd
- name: Install web build dependencies
if: steps.web-cache.outputs.ready != 'true'
run: USER="$(id -un)" .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt python3-pil
- name: Fetch locked Ziran packages
if: steps.web-cache.outputs.ready != 'true'
uses: ./.github/actions/ziran-packages
- name: Set up the pinned Emscripten SDK
if: steps.web-cache.outputs.ready != 'true'
uses: ./.github/actions/emscripten
- name: Build the web app from this revision
if: steps.web-cache.outputs.ready != 'true'
env:
WEB_INPUT_KEY: ${{ steps.web-inputs.outputs.key }}
run: |
set -eu
rm -f build/dist/web/index.html build/dist/web/index.js build/dist/web/index.wasm
make -j2 PACKAGE_FLAGS=--locked WEB_CACHE_BUSTER="$WEB_INPUT_KEY" build/dist/web/index.html
sh site/web-build-receipt.sh write build/dist/web "$WEB_INPUT_KEY"
- name: Verify the exact web app artifact
env:
WEB_INPUT_KEY: ${{ steps.web-inputs.outputs.key }}
run: sh site/web-build-receipt.sh verify build/dist/web "$WEB_INPUT_KEY"
- name: Save the verified web build for the next deployment
if: gitea.event_name != 'pull_request' && steps.web-cache.outputs.ready != 'true' && steps.web-restore.outputs.cache-hit != 'true'
uses: https://github.com/actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830
continue-on-error: true
with:
path: build/dist/web
key: breeze-web-${{ runner.os }}-${{ runner.arch }}-${{ steps.web-inputs.outputs.key }}
- name: Fetch the pinned site icons from Gitea
run: |
set -eu
kryon_dir="$PWD/build/site-kryon"
sh site/fetch-kryon-icons.sh "$kryon_dir"
printf 'KRYON_DIR=%s\n' "$kryon_dir" >> "$GITHUB_ENV"
- name: Select the verified web app origin
if: gitea.event_name != 'pull_request'
run: |
set -eu
host=innerbreeze.org
if ! sh site/check-account-origin.sh "$host"; then
host=inbe.waozi.xyz
sh site/check-account-origin.sh "$host"
fi
printf 'SITE_APP_HOST=%s\n' "$host" >> "$GITHUB_ENV"
- name: Build site with the source-built web app and signed download repository
env:
APT_SIGNING_KEY: ${{ gitea.event_name != 'pull_request' && secrets.APT_SIGNING_KEY || '' }}
run: SITE_WEB_DIR="$PWD/build/dist/web" sh site/build-production.sh
- name: Test website routes, assets and Telegram bridge
run: |
node tests/site_assets_test.mjs
sh tests/site_web_build_test.sh
# The APT fixture is designed to check package discovery without root.
if [ "$(id -u)" -eq 0 ]; then
runuser -u nobody -- sh tests/apt_repo_test.sh
else
sh tests/apt_repo_test.sh
fi
node tests/telegram_bridge_test.mjs
- name: Deploy current master to Cloudflare Pages
if: gitea.event_name != 'pull_request'
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
WRANGLER_SEND_METRICS: 'false'
REVISION: ${{ gitea.sha }}
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$REVISION"
test "$(git ls-remote origin refs/heads/master | cut -f1)" = "$REVISION"
: "${CLOUDFLARE_API_TOKEN:?Missing Gitea Pages deployment token}"
: "${CLOUDFLARE_ACCOUNT_ID:?Missing Gitea Pages account ID}"
# Verify the public domain and the selected app origin before uploading.
curl -fsS --max-time 25 https://innerbreeze.org/ -o /dev/null
sh site/check-account-origin.sh "$SITE_APP_HOST"
npm exec --yes [email protected] -- wrangler pages deploy build/site \
--project-name=inbe --branch=master --commit-hash="$REVISION" --commit-dirty=false
sh site/verify-deployment.sh "$REVISION"