Build and Deploy to GitHub Pages #53
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
name: Build and Deploy to GitHub Pages | |
on: | |
# trigger manually for now | |
workflow_dispatch: | |
# push: | |
# branches: | |
# - master | |
jobs: | |
build: | |
runs-on: ["runs-on","runner=2cpu-linux-x64","image=ubuntu24-amd64"] | |
steps: | |
# Checkout the main repository | |
- name: Checkout this repository | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
# Checkout the ZML repository into a separate folder | |
- name: Checkout ZML repository | |
uses: actions/checkout@v3 | |
with: | |
repository: zml/zml | |
token: ${{ secrets.ORG_PAT }} | |
path: zml | |
ref: master | |
# Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
# Set up Zig | |
- uses: mlugg/setup-zig@v1 | |
with: | |
version: 0.13.0 | |
mirror: 'https://mirror.zml.ai/zig' | |
# Run scripts to build the static website with Zine | |
- name: Run build scripts | |
run: | | |
./01-PREPARE-FOR-EDITS.sh | |
eval "$(ssh-agent -s)" | |
ssh-keyscan -t ed25519 github.com > ~/.ssh/known_hosts | |
ssh-add - <<< "${{ secrets.DEPLOY_KEY }}" | |
./02-BUILD.sh --release=small | |
# Checkout the docs branch | |
- name: Checkout the docs branch | |
uses: actions/checkout@v3 | |
with: | |
ref: docs # The branch that will hold the generated GitHub Pages content | |
path: gh-pages # Work in a separate directory to avoid conflicts | |
# probably don't need the token - but the branch must exist | |
token: ${{ secrets.ORG_PAT }} | |
# Copy the generated files to the docs branch | |
- name: Copy generated files | |
run: | | |
cp -r WORKSPACE/zig-out/* gh-pages/ | |
# Commit and push changes to the docs branch | |
- name: Commit and push changes | |
run: | | |
cd gh-pages | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
date >> README.md | |
git add . | |
git remote add sshtarget [email protected]:zml/docs | |
eval "$(ssh-agent -s)" | |
ssh-keyscan -t ed25519 github.com > ~/.ssh/known_hosts | |
ssh-add - <<< "${{ secrets.DEPLOY_KEY }}" | |
git commit -m "Update GitHub Pages" | |
git push sshtarget docs | |
# alternative with the x-access url | |
# but: the token only has read access!!!! | |
# git push https://x-access-token:${{ secrets.ORG_PAT }}@github.com/zml/zml.git docs |