94 lines
3.4 KiB
YAML
94 lines
3.4 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'
|
|
# The Ubuntu label is registered by the Build runners.
|
|
runs-on: alpha-ubuntu24.04
|
|
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: 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: 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 published web app and signed download repository
|
|
env:
|
|
APT_SIGNING_KEY: ${{ gitea.event_name != 'pull_request' && secrets.APT_SIGNING_KEY || '' }}
|
|
run: sh site/build-production.sh
|
|
|
|
- name: Test website routes, assets and Telegram bridge
|
|
run: |
|
|
node tests/site_assets_test.mjs
|
|
# 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"
|