GitHub Pages #137
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: GitHub Pages | |
on: | |
push: | |
branches: | |
- www | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build + deploy www branch to ctbk.dev via GitHub Pages | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.WWW_DEPLOY_KEY }} | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
cache-dependency-path: www/pnpm-lock.yaml | |
- name: Cache Puppeteer | |
uses: actions/cache@v4 | |
with: | |
key: puppeteer | |
path: ~/.cache/puppeteer | |
- name: Install | |
working-directory: www | |
run: | | |
pnpm install | |
pnpm up puppeteer | |
- name: Install chrome | |
run: pnpx puppeteer browsers install chrome | |
- name: Inspect puppeteer cache | |
run: tree -L 3 ~/.cache/puppeteer | |
- name: Check for puppeteer install script | |
run: ls -l www/node_modules/.pnpm/puppeteer* | |
- name: Inspect puppeteer cache | |
run: tree -L 3 ~/.cache/puppeteer | |
- name: Build | |
working-directory: www | |
run: | | |
pnpm run build | |
touch out/.nojekyll | |
- name: Serve Files | |
uses: Eun/http-server-action@v1.0.6 | |
with: | |
directory: www/out | |
index-files: | | |
["index.html", "index.htm"] | |
- name: Regenerate screenshots | |
working-directory: www | |
run: node screenshots.js -h localhost:8080 -l 120000 | |
- name: Push + re-run, if screenshots changed | |
id: screenshots | |
run: | | |
if git diff --name-only -- www/public/screenshots | grep -v ctbk-stations; then | |
git add www/public/screenshots | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "github@actions" | |
git commit -m "Update screenshots" | |
git pull origin www | |
echo "Pushing www" | |
git push origin HEAD:www | |
echo "Updating main branch" | |
git fetch --unshallow origin main | |
git pull origin main | |
git push origin HEAD:main | |
echo "REGENERATED=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Deploy to GH Page | |
uses: JamesIves/github-pages-deploy-action@4.1.1 | |
if: steps.screenshots.outputs.REGENERATED != 'true' | |
with: | |
branch: ghp | |
folder: www/out |