Skip to content

Commit 637c999

Browse files
authored
Stop update-api-spec from editing open PRs (#80)
The behavior of `peter-evans/create-pull-request` is to check if either the base or target branches have changed and either keep creating new PRs or update an open PR (default), force-pushing and editing its description. Prevent the action from running on open PRs entirely, because API spec updates will often require manual changes to be pushed, and the workflow shouldn't force-push over them.
1 parent cddc266 commit 637c999

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/update-api-spec.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,24 @@ jobs:
3333
echo "NEW_VERSION=$(cat new.txt)" >> $GITHUB_ENV
3434
fi
3535
rm new.txt || true
36+
- name: Check for existing PR
37+
if: ${{ env.NEW_VERSION }}
38+
run: |
39+
set -u
40+
update_branch="feature/api-spec-$NEW_VERSION"
41+
echo "UPDATE_BRANCH=$update_branch" >> $GITHUB_ENV
42+
if git ls-remote --exit-code --heads origin "$update_branch"; then
43+
echo "EXISTING_PR=true" >> $GITHUB_ENV
44+
fi
3645
- name: 'Create PR'
37-
if: ${{ inputs.dry_run != true && env.NEW_VERSION }}
46+
if: ${{ inputs.dry_run != true && env.NEW_VERSION && !env.EXISTING_PR }}
3847
uses: peter-evans/create-pull-request@v5
3948
with:
40-
branch: "feature/api-spec-${{ env.NEW_VERSION }}"
49+
branch: "${{ env.UPDATE_BRANCH }}"
4150
commit-message: "Bump GE API spec version to ${{ env.NEW_VERSION }}"
4251
title: "Bump GE API spec version to ${{ env.NEW_VERSION }}"
4352
body: "https://docs.gradle.com/enterprise/api-manual/#release_history"
4453
author: "github-actions <github-actions@github.com>"
4554
committer: "github-actions <github-actions@github.com>"
4655
add-paths: "gradle.properties"
56+
delete-branch: true

0 commit comments

Comments
 (0)