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 0ec9799 commit 46cafee
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/update-subtree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,24 @@ jobs:
echo "CURRENT_COMMIT_HASH=${CURRENT_COMMIT_HASH}" >> $GITHUB_ENV
echo "NEXT_COMMIT_HASH=${NEXT_COMMIT_HASH}" >> $GITHUB_ENV
- name: Check for existing pull requests
run: |
cd verify-rust-std
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
env:
GH_TOKEN: ${{ github.token }}

- name: Update subtree/library locally
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
run: |
cd rust-tmp
Expand Down Expand Up @@ -89,8 +106,8 @@ jobs:
echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: ${{ env.MERGE_CONFLICTS != 'noop' }}
- 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 +121,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 +141,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 +156,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 46cafee

Please sign in to comment.