Skip to content

Update screenshot

Update screenshot #9

Workflow file for this run

name: Update screenshot
on:
schedule:
# Sunday at 22:00 UTC+7.
# GitHub Actions cron uses UTC, so this runs Sunday at 15:00 UTC.
- cron: "0 15 * * 0"
workflow_dispatch:
permissions:
contents: write
jobs:
screenshot:
name: Create and commit screenshot
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Run screenshot script
run: npm run screenshot
- name: Verify screenshot exists
run: test -f .github/screenshot.png
- name: Commit screenshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
REF_NAME: ${{ github.ref_name }}
run: |
git config user.name "davidsneighbour"
git config user.email "davidsneighbour@users.noreply.github.com"
git add .github/screenshot.png
git diff --cached --quiet && { echo "No screenshot changes to commit."; exit 0; }
git commit -m "chore: update screenshot"
REMOTE="https://x-access-token:${GITHUB_TOKEN}"
REMOTE="${REMOTE}@github.com/${REPOSITORY}.git"
git push "${REMOTE}" "HEAD:refs/heads/${REF_NAME}"