71 lines
2.4 KiB
YAML
71 lines
2.4 KiB
YAML
name: Build site
|
|
|
|
on:
|
|
- push
|
|
- workflow_dispatch
|
|
|
|
jobs:
|
|
build:
|
|
# NOTE: must match your act_runner labels (e.g. ubuntu-latest, ubuntu-24.04).
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Bootstrap pinned toolchain
|
|
run: ./scripts/bootstrap.sh
|
|
|
|
- name: Build site
|
|
run: ./scripts/calepin.sh compile site public
|
|
|
|
# The official upload-artifact@v4 refuses to run on Gitea (it detects a
|
|
# non-GitHub server and aborts with GHESNotSupportedError). v3 uses the
|
|
# artifact API that Gitea implements. On Gitea >= 1.22 with a current
|
|
# act_runner, christopherhx/gitea-upload-artifact@v4 is a drop-in
|
|
# replacement if you want the v4 API.
|
|
- name: Upload site artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: public
|
|
path: public/
|
|
|
|
deploy:
|
|
needs: build
|
|
# Publish only from main; move the gate to publish from another branch.
|
|
if: github.ref == 'refs/heads/main'
|
|
# Write access for the automatic Actions token to push the pages branch.
|
|
permissions:
|
|
contents: write
|
|
# NOTE: must match your act_runner labels (e.g. ubuntu-latest, ubuntu-24.04).
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download site artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: public
|
|
path: public
|
|
|
|
- name: Check artifact layout
|
|
run: test -f public/index.html
|
|
|
|
# Publishing interfaces with prod; it never runs under local act tests
|
|
# (act sets env.ACT, the Gitea runner does not). The force-push to the
|
|
# `pages` branch is what triggers the git-pages webhook.
|
|
- name: Publish to pages branch
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
if [ -z "$GITEA_TOKEN" ]; then
|
|
echo "::error::Missing GITEA_TOKEN (the automatic Actions token)."
|
|
exit 1
|
|
fi
|
|
cd public
|
|
git init -q -b pages .
|
|
git config user.name "Yggdrasil CI"
|
|
git config user.email "ci@noreply.kb28.ch"
|
|
git add -A
|
|
git commit -q -m "Publish site from ${GITHUB_SHA}"
|
|
repo_host="${GITHUB_SERVER_URL#*://}"
|
|
repo_host="${repo_host%/}"
|
|
git push -q --force "https://${GITHUB_REPOSITORY_OWNER}:${GITEA_TOKEN}@${repo_host}/${GITHUB_REPOSITORY}.git" pages
|