Skip to content

Take screenshots

Take screenshots #3937

Workflow file for this run

name: Take screenshots
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
shot-scraper:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v3
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Playwright browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright/
key: ${{ runner.os }}-browsers
- name: Cache OxiPNG
uses: actions/cache@v3
with:
path: ~/.cargo/
key: ${{ runner.os }}-cargo
- name: Install dependencies
run: |
pip install shot-scraper
which oxipng || cargo install oxipng
shot-scraper install
- name: Take retina shots
run: |
shot-scraper multi live.shots.yml --retina
- name: Optimize PNGs
run: |-
oxipng -o 4 -i 0 --strip safe screenshots/**/*.png
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- run: git checkout -b update-screenshot-${{ steps.date.outputs.date }}
- name: Check for changes
id: git-check
run: |
git add screenshots
git status --porcelain
echo "changes=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
- name: Commit and push if there are changes
if: steps.git-check.outputs.changes > 0
run: |
git config --global user.email "workflow-automation@coreyja.com"
git config --global user.name "Coreyja Workflow Automation"
git commit -m "Update daily screenshots for ${{ steps.date.outputs.date }}"
git push --set-upstream origin update-screenshot-${{ steps.date.outputs.date }}
- name: Install OIDC Client from Core Package
if: steps.git-check.outputs.changes > 0
run: npm install @actions/core@1.6.0 @actions/http-client
- name: Get Id Token
if: steps.git-check.outputs.changes > 0
uses: actions/github-script@v6
id: idtoken
with:
script: |
const coredemo = require('@actions/core')
let id_token = await coredemo.getIDToken()
coredemo.setOutput('id_token', id_token)
console.log(id_token)
- name: Make PR
if: steps.git-check.outputs.changes > 0
run: |
curl -X POST https://workflow-automation.fly.dev/create-pr \
-H "Content-Type: application/json" \
-d '{"github_oidc_jwt": "${{ steps.idtoken.outputs.id_token }}", "owner": "coreyja", "repo": "coreyja.com", "base_branch": "main", "head_branch": "update-screenshot-${{ steps.date.outputs.date }}", "title": "Update Daily Screenshot -- ${{ steps.date.outputs.date }}", "body": "Automated daily screenshot update for ${{ steps.date.outputs.date }}"}'