Skip to content

Commit af95c41

Browse files
committed
Subtree update automation: create merge PR even when subtree/library is up-to-date
When the PR updating the `subtree/library` branch has been merged already we may still need to bring updates into `main` that haven't previously been added to a pull request. This situation arises when an older merge-into-main PR was still open at the time where the subtree automation creating the `subtree/library` update PR ran. The changes in this PR avoid this problem by making sure the merge-into-main part of the automation is run even when `subtree/library` is already up-to-date.
1 parent 659982c commit af95c41

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

.github/workflows/update-subtree.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ jobs:
126126
UPSTREAM_HEAD=$(git log --format=%H -n 1 rust-filtered/subtree/library)
127127
if [ "${UPSTREAM_HEAD}" = "${UPSTREAM_FROM}" ]; then
128128
echo "Nothing to do, ${UPSTREAM_FROM} matches ${UPSTREAM_HEAD} (${SUBTREE_HEAD_MSG})"
129-
echo "MERGE_CONFLICTS=noop" >> $GITHUB_ENV
129+
echo "SUBTREE_PR_REQUIRED=no" >> $GITHUB_ENV
130130
else
131131
git branch --set-upstream-to=origin/subtree/library
132-
echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
132+
echo "SUBTREE_PR_REQUIRED=yes" >> $GITHUB_ENV
133133
fi
134134
135135
- name: Create Pull Request to update subtree/library
136-
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.SUBTREE_PR_EXISTS == 'no' }}
136+
if: ${{ env.SUBTREE_PR_REQUIRED == 'yes' && env.SUBTREE_PR_EXISTS == 'no' }}
137137
uses: peter-evans/create-pull-request@v7
138138
with:
139139
title: 'Update subtree/library to ${{ env.NEXT_TOOLCHAIN_DATE }}'
@@ -151,7 +151,7 @@ jobs:
151151
path: verify-rust-std
152152

153153
- name: Merge subtree/library changes
154-
if: ${{ env.MERGE_CONFLICTS != 'noop' && env.MERGE_PR_EXISTS == 'no' }}
154+
if: ${{ env.CURRENT_TOOLCHAIN_DATE != env.NEXT_TOOLCHAIN_DATE && env.MERGE_PR_EXISTS == 'no' }}
155155
run: |
156156
cd verify-rust-std
157157
# create-pull-request resets branches locally, implying that
@@ -160,7 +160,9 @@ jobs:
160160
git checkout -t -b subtree/library origin/update-subtree/library
161161
else
162162
git checkout subtree/library
163-
git reset --hard origin/update-subtree/library
163+
if [ "${SUBTREE_PR_REQUIRED}" = "yes" ]; then
164+
git reset --hard origin/update-subtree/library
165+
fi
164166
fi
165167
git checkout main
166168

0 commit comments

Comments
 (0)