Skip to content

Commit

Permalink
only create PRs if they don't already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynzech committed Feb 21, 2025
1 parent b764eeb commit a77c398
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/update-subtree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,21 @@ jobs:
echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: ${{ env.MERGE_CONFLICTS != 'noop' }}
- name: Check for existing pull requests
run: |
if gh pr list --json title --jq '.[] | select(.title == "Update subtree/library to ${{ env.NEXT_TOOLCHAIN_DATE }}") | .title' | grep -q .; then
echo "SUBTREE_PR_EXISTS=yes" >> $GITHUB_ENV
else
echo "SUBTREE_PR_EXISTS=no" >> $GITHUB_ENV
fi
if gh pr list --json title --jq '.[] | select(.title == "Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}") | .title' | grep -q .; then
echo "MERGE_PR_EXISTS=yes" >> $GITHUB_ENV
else
echo "MERGE_PR_EXISTS=no" >> $GITHUB_ENV
fi
- name: Create Pull Request to update subtree/library
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.SUBTREE_PR_EXISTS == 'no' }}
uses: peter-evans/create-pull-request@v7
with:
title: 'Update subtree/library to ${{ env.NEXT_TOOLCHAIN_DATE }}'
Expand All @@ -104,7 +117,7 @@ jobs:
path: verify-rust-std

- name: Merge subtree/library changes
if: ${{ env.MERGE_CONFLICTS != 'noop' }}
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.MERGE_PR_EXISTS == 'no' }}
run: |
cd verify-rust-std
git checkout main
Expand All @@ -124,7 +137,7 @@ jobs:
commit -m "Update toolchain to ${NEXT_TOOLCHAIN_DATE}" rust-toolchain.toml
- name: Create Pull Request without conflicts
if: ${{ env.MERGE_CONFLICTS == 'no' }}
if: ${{ env.MERGE_CONFLICTS == 'no' && env.MERGE_PR_EXISTS == 'no' }}
uses: peter-evans/create-pull-request@v7
with:
title: 'Merge subtree update for toolchain nightly-${{ env.NEXT_TOOLCHAIN_DATE }}'
Expand All @@ -139,7 +152,7 @@ jobs:
path: verify-rust-std

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

0 comments on commit a77c398

Please sign in to comment.