Skip to content

Commit dbbac68

Browse files
committed
Update update-from-template.yml
xdev-software/java-template#8
1 parent b68fe41 commit dbbac68

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

.github/workflows/update-from-template.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Update from Template
22

33
# This workflow keeps the repo up to date with changes from the template repo (REMOTE_URL)
4-
# It duplicates the REMOTE_BRANCH (into UPDATE_BRANCH) and tries to merge it into the
4+
# It duplicates the REMOTE_BRANCH (into UPDATE_BRANCH) and tries to merge it into
55
# this repos default branch (which is checked out here)
66
# Note that this requires a PAT (Personal Access Token) - at best from a servicing account
7+
# PAT permissions: read:discussion, read:org, repo, workflow
78
# Also note that you should have at least once merged the template repo into the current repo manually
89
# otherwise a "refusing to merge unrelated histories" error might occur.
910

@@ -135,8 +136,9 @@ jobs:
135136
136137
echo "create_update_branch_pr=0" >> $GITHUB_OUTPUT
137138
echo "create_update_branch_merged_pr=1" >> $GITHUB_OUTPUT
139+
echo "try_close_update_branch_pr=1" >> $GITHUB_OUTPUT
138140
139-
- name: PR update_branch
141+
- name: Create/Update PR update_branch
140142
if: steps.manage-branches.outputs.create_update_branch_pr == 1
141143
env:
142144
GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}
@@ -147,8 +149,16 @@ jobs:
147149
gh_pr_up -B "${{ steps.manage-branches.outputs.base_branch }}" \
148150
--title "Update from template" \
149151
--body "An automated PR to sync changes from the template into this repo"
152+
153+
# Ensure that only a single PR is open (otherwise confusion and spam)
154+
- name: Close PR update_branch
155+
if: steps.manage-branches.outputs.try_close_update_branch_pr == 1
156+
env:
157+
GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}
158+
run: |
159+
gh pr close "${{ env.UPDATE_BRANCH }}" || true
150160
151-
- name: PR update_branch_merged
161+
- name: Create/Update PR update_branch_merged
152162
if: steps.manage-branches.outputs.create_update_branch_merged_pr == 1
153163
env:
154164
GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}

0 commit comments

Comments
 (0)