Update screenshots #95
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@v3 | |
with: | |
ssh-key: ${{ secrets.WWW_DEPLOY_KEY }} | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
cache-dependency-path: www/pnpm-lock.yaml | |
- name: Install | |
working-directory: www | |
run: pnpm install | |
- 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: Install chrome | |
run: npx puppeteer browsers install chrome | |
- 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 |