Skip to content

Commit da1b675

Browse files
joeyparrishavelad
authored andcommitted
ci: Check if screenshot PR exists before creating new one (#8119)
This keeps the job from failing if a one-off PR for screenshots already exists.
1 parent 7a7f632 commit da1b675

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/update-screenshots.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,25 @@ jobs:
161161
# If there were no changes, this will do nothing, but succeed.
162162
git push -f origin HEAD:refs/heads/update-screenshots
163163
164-
# Create a PR.
165-
gh pr create \
166-
--title 'chore: Update all screenshots' \
167-
--body ':robot:' \
168-
--reviewer 'shaka-project/shaka-player'
164+
# Check if a PR already exists.
165+
REPO_OWNER=$(echo "${{ github.repository }}" | cut -f 1 -d /)
166+
REPO_NAME=$(echo "${{ github.repository }}" | cut -f 2 -d /)
167+
gh pr list \
168+
--json number,headRepository,headRefName,headRepositoryOwner \
169+
| jq "map(select(
170+
.headRepositoryOwner.login == \"$REPO_OWNER\" and
171+
.headRepository.name == \"$REPO_NAME\" and
172+
.headRefName == \"update-screenshots\").number)[0]" > pr-number
173+
174+
if [[ "$(cat pr-number)" == "null" ]]; then
175+
# Create a PR.
176+
gh pr create \
177+
--title 'chore: Update all screenshots' \
178+
--body ':robot:' \
179+
--reviewer 'shaka-project/shaka-player'
180+
fi
181+
# If a PR already existed, pushing to the branch was enough to update
182+
# it.
169183
170184
- name: Update PR
171185
if: ${{ inputs.pr != '' }}

0 commit comments

Comments
 (0)