Skip to content

Commit 46cafee

Browse files
author
Carolyn Zech
committed
only create PRs if they don't already exist
1 parent 0ec9799 commit 46cafee

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/update-subtree.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,24 @@ jobs:
5959
echo "CURRENT_COMMIT_HASH=${CURRENT_COMMIT_HASH}" >> $GITHUB_ENV
6060
echo "NEXT_COMMIT_HASH=${NEXT_COMMIT_HASH}" >> $GITHUB_ENV
6161
62+
- name: Check for existing pull requests
63+
run: |
64+
cd verify-rust-std
65+
if gh pr list --json title --jq '.[] | select(.title == "Update subtree/library to ${{ env.NEXT_TOOLCHAIN_DATE }}") | .title' | grep -q .; then
66+
echo "SUBTREE_PR_EXISTS=yes" >> $GITHUB_ENV
67+
else
68+
echo "SUBTREE_PR_EXISTS=no" >> $GITHUB_ENV
69+
fi
70+
if gh pr list --json title --jq '.[] | select(.title == "Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}") | .title' | grep -q .; then
71+
echo "MERGE_PR_EXISTS=yes" >> $GITHUB_ENV
72+
else
73+
echo "MERGE_PR_EXISTS=no" >> $GITHUB_ENV
74+
fi
75+
env:
76+
GH_TOKEN: ${{ github.token }}
77+
6278
- name: Update subtree/library locally
79+
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
6380
run: |
6481
cd rust-tmp
6582
@@ -89,8 +106,8 @@ jobs:
89106
echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
90107
fi
91108
92-
- name: Create Pull Request
93-
if: ${{ env.MERGE_CONFLICTS != 'noop' }}
109+
- name: Create Pull Request to update subtree/library
110+
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.SUBTREE_PR_EXISTS == 'no' }}
94111
uses: peter-evans/create-pull-request@v7
95112
with:
96113
title: 'Update subtree/library to ${{ env.NEXT_TOOLCHAIN_DATE }}'
@@ -104,7 +121,7 @@ jobs:
104121
path: verify-rust-std
105122

106123
- name: Merge subtree/library changes
107-
if: ${{ env.MERGE_CONFLICTS != 'noop' }}
124+
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.MERGE_PR_EXISTS == 'no' }}
108125
run: |
109126
cd verify-rust-std
110127
git checkout main
@@ -124,7 +141,7 @@ jobs:
124141
commit -m "Update toolchain to ${NEXT_TOOLCHAIN_DATE}" rust-toolchain.toml
125142
126143
- name: Create Pull Request without conflicts
127-
if: ${{ env.MERGE_CONFLICTS == 'no' }}
144+
if: ${{ env.MERGE_CONFLICTS == 'no' && env.MERGE_PR_EXISTS == 'no' }}
128145
uses: peter-evans/create-pull-request@v7
129146
with:
130147
title: 'Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}'
@@ -139,7 +156,7 @@ jobs:
139156
path: verify-rust-std
140157

141158
- name: Create Pull Request with conflicts
142-
if: ${{ env.MERGE_CONFLICTS == 'yes' }}
159+
if: ${{ env.MERGE_CONFLICTS == 'yes' && env.MERGE_PR_EXISTS == 'no' }}
143160
uses: peter-evans/create-pull-request@v7
144161
with:
145162
title: 'Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}'

0 commit comments

Comments
 (0)