-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Credit to Simon Willison for his awesome work: | ||
# https://github.com/simonw/shot-scraper-template/blob/main/.github/workflows/shots.yml | ||
name: screenshots | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
shot-scraper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- uses: actions/cache@v3 | ||
name: Configure pip caching | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.screenshots.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Cache Playwright browsers | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/ms-playwright/ | ||
key: ${{ runner.os }}-browsers | ||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements.screenshots.txt | ||
- name: Install Playwright dependencies | ||
run: | | ||
shot-scraper install | ||
- uses: actions/github-script@v7 | ||
name: Create shots.yml if missing on first run | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
if (!fs.existsSync('shots.yml')) { | ||
const desc = context.payload.repository.description; | ||
let line = ''; | ||
if (desc && (desc.startsWith('http://') || desc.startsWith('https://'))) { | ||
line = `- url: ${desc}` + '\n output: shot.png\n height: 800'; | ||
} else { | ||
line = '# - url: https://www.example.com/\n# output: shot.png\n# height: 800'; | ||
} | ||
fs.writeFileSync('shots.yml', line + '\n'); | ||
} | ||
- name: Take shots | ||
run: | | ||
shot-scraper multi shots.yml | ||
- name: Commit and push | ||
run: |- | ||
git config user.name "Automated" | ||
git config user.email "[email protected]" | ||
git add -A | ||
timestamp=$(date -u) | ||
git commit -m "${timestamp}" || exit 0 | ||
git pull --rebase | ||
git push |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shot-scraper |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- url: https://manikure.netlify.app/ | ||
output: application.png | ||
width: 1280 | ||
height: 800 |