149 lines
4.6 KiB
YAML
149 lines
4.6 KiB
YAML
name: Cloudflare Pages
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- Release
|
|
types:
|
|
- completed
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
workflow_dispatch:
|
|
inputs:
|
|
released_web:
|
|
description: Use the published web app for a website-only update
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: pages-${{ github.event.workflow_run.head_branch || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Site
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.workflow_run.head_sha || github.ref }}
|
|
submodules: recursive
|
|
lfs: true
|
|
|
|
- name: Set up Node.js for the web build
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Install Packages
|
|
if: ${{ !inputs.released_web }}
|
|
timeout-minutes: 15
|
|
run: .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt
|
|
|
|
- name: Set Up Emscripten
|
|
if: ${{ !inputs.released_web }}
|
|
run: |
|
|
set -euo pipefail
|
|
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
|
"$HOME/emsdk/emsdk" install latest
|
|
"$HOME/emsdk/emsdk" activate latest
|
|
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
|
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
|
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
|
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
|
|
|
- name: Download Released Web App
|
|
if: ${{ inputs.released_web }}
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
version=$(sed -n 's/^#define APP_VERSION_STRING "\([^"]*\)"/\1/p' src/core/version.h)
|
|
test -n "$version"
|
|
mkdir -p build/released-web build/dist/web
|
|
gh release download "v$version" --pattern inbe-web.zip --dir build/released-web
|
|
unzip -q build/released-web/inbe-web.zip -d build/dist/web
|
|
test -s build/dist/web/index.wasm
|
|
|
|
- name: Build Site
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "$RELEASED_WEB" = "true" ]; then
|
|
make package-unpackaged-assets
|
|
sh site/build.sh
|
|
else
|
|
export PATH="$INBE_NODE_BIN:$PATH"
|
|
node --version
|
|
make site
|
|
fi
|
|
test -f build/site/index.html
|
|
test -f build/site/build/web/index.html
|
|
test -f build/site/build/web/index.js
|
|
test -f build/site/build/web/index.wasm
|
|
if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then
|
|
make site-release-assets-check
|
|
else
|
|
echo "Skipping release asset availability check for pull request build"
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
RELEASED_WEB: ${{ inputs.released_web }}
|
|
|
|
- name: Upload Site Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: inbe-site
|
|
path: build/site
|
|
if-no-files-found: error
|
|
|
|
deploy-preview:
|
|
name: Deploy Preview
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: github.event_name == 'pull_request'
|
|
|
|
steps:
|
|
- name: Download Site Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: inbe-site
|
|
path: build/site
|
|
|
|
- name: Deploy Preview To Cloudflare Pages
|
|
uses: cloudflare/wrangler-action@v3
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
command: pages deploy build/site --project-name=inbe --branch=${{ github.head_ref || github.ref_name }}
|
|
|
|
deploy-production:
|
|
name: Deploy Production
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: |
|
|
(github.event_name == 'workflow_run' &&
|
|
github.event.workflow_run.conclusion == 'success' &&
|
|
github.event.workflow_run.head_branch == 'master') ||
|
|
(github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master')
|
|
|
|
steps:
|
|
- name: Download Site Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: inbe-site
|
|
path: build/site
|
|
|
|
- name: Deploy Production To Cloudflare Pages
|
|
uses: cloudflare/wrangler-action@v3
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
command: pages deploy build/site --project-name=inbe --branch=master
|