-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Experimental workflow to update screenshots in a PR (#4991)
Untested. A workflow must exist in the main branch before a version of it from any branch can be triggered.
- Loading branch information
1 parent
ee77d35
commit a8c2491
Showing
2 changed files
with
80 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
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,63 @@ | ||
name: Update All Screenshots | ||
# Updates all screenshots on an existing PR, assuming permission has been given | ||
# to maintainers to make edits. | ||
|
||
on: | ||
workflow_dispatch: | ||
# Allows for manual triggering on PRs. They should be reviewed first, to | ||
# avoid malicious code executing in the lab. | ||
inputs: | ||
pr: | ||
description: "A PR number to build and test in the lab, then update all the screenshots." | ||
required: true | ||
|
||
jobs: | ||
run-lab-tests: | ||
name: Get Selenium Lab Screenshots | ||
uses: ./.github/workflows/selenium-lab-tests.yaml | ||
with: | ||
pr: ${{ github.event.inputs.pr }} | ||
test_filter: 'layout' | ||
ignore_test_status: true | ||
|
||
update-pr: | ||
name: Update PR | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: refs/pull/${{ github.event.inputs.pr }}/head | ||
|
||
- name: Get artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Update screenshots | ||
run: | | ||
# Unpack screenshots from the lab. | ||
for i in screenshots-*.zip; do | ||
unzip -d test/test/assets/screenshots/ "$i" | ||
done | ||
# Update the official screenshots for any that has visibly changed. | ||
# This is not a byte-for-byte comparison. | ||
./build/updateScreenshots.py | ||
# Emulate the actions bot. | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
# Update the PR. | ||
git add test/test/assets/screenshots/*/*.png | ||
git commit -m ':robot: Update all screenshots' | ||
PR_API_URL="/repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }}" | ||
REMOTE=$(gh api $GH_API_URL | jq -r .head.repo.html_url) | ||
BRANCH=$(gh api $GH_API_URL | jq -r .head.ref) | ||
git push "$REMOTE" "$BRANCH" | ||
- name: Debug | ||
uses: mxschmitt/[email protected] | ||
with: | ||
limit-access-to-actor: true | ||
if: failure() |