Skip to content

Update screenshot

Update screenshot #13

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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
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}"