69 lines
2.8 KiB
YAML
69 lines
2.8 KiB
YAML
name: Update Gallery Screenshots
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request_target:
|
|
types: [opened, synchronize, reopened]
|
|
paths:
|
|
- "blueprints/**/blueprint.json"
|
|
- ".github/workflows/screenshots.yml"
|
|
- "scripts/screenshot-blueprints.ts"
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
render:
|
|
runs-on: ubuntu-latest
|
|
# Only run for PRs from the same repository (not forks)
|
|
if: |
|
|
github.event_name == 'workflow_dispatch' ||
|
|
github.event_name == 'schedule' ||
|
|
github.event_name == 'pull_request' ||
|
|
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name == github.repository)
|
|
steps:
|
|
- name: Checkout PR branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.ref || github.ref }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- run: npm i
|
|
- run: npx playwright install --with-deps
|
|
|
|
- name: Take screenshots
|
|
run: npm run shots
|
|
|
|
- name: Check for changes
|
|
id: check_changes
|
|
run: |
|
|
git add blueprints/*/screenshot.jpg
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Commit and push to PR
|
|
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && steps.check_changes.outputs.has_changes == 'true'
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add blueprints/*/screenshot.jpg
|
|
git commit -m "chore: add missing Blueprint screenshots"
|
|
git push
|
|
|
|
- name: Create PR for scheduled/manual runs
|
|
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && steps.check_changes.outputs.has_changes == 'true'
|
|
uses: peter-evans/create-pull-request@v6
|
|
with:
|
|
commit-message: "chore: refresh Blueprint screenshots"
|
|
title: "Refresh Blueprint screenshots"
|
|
body: "Automated update of gallery screenshots."
|
|
branch: ci/update-screenshots
|
|
delete-branch: true
|