Skip to content

Commit 4bd944b

Browse files
author
Philip Keicher
committed
skip PR creation if PR is already open
1 parent 35b75ce commit 4bd944b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/sync_overleaf.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,21 @@ jobs:
3333
env:
3434
OVERLEAF_TOKEN: ${{ secrets.OVERLEAF_TOKEN }}
3535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
- name: create pull request
36+
- name: check for existing PRs
37+
id: check_for_existing_PRs
3738
if: steps.sync_overleaf.outputs.commitDiffCount > 0
39+
run: |
40+
prs=$(gh pr list \
41+
--repo "$GITHUB_REPOSITORY" \
42+
--head 'sync_overleaf' \
43+
--base 'master' \
44+
--json 'Merge sync_overleaf into master' \
45+
--jq 'length')
46+
if ((prs > 0)); then
47+
echo "skip=true" >> "$GITHUB_OUTPUT"
48+
fi
49+
- name: create pull request
50+
if: ((steps.sync_overleaf.outputs.commitDiffCount > 0) && (steps.check_for_existing_PRs.outputs.skip != 'true'))
3851
run: gh pr create -B master -H sync_overleaf --title 'Merge sync_overleaf into master' --body 'Created by Github action'
3952
env:
4053
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)