Skip to content

Commit 4207b88

Browse files
committed
fix: force-push branch and skip duplicate PR on re-run
When an issue is edited and the workflow re-triggers, the branch already exists remotely. Force-push updates it with the latest content. If a PR is already open for that branch, skip creation to avoid an error.
1 parent 4736010 commit 4207b88

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/process-issue.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@ jobs:
6464
git checkout -b "$BRANCH"
6565
git add data/ docs/data.json docs/index.html README.md
6666
git commit -m "feat: add entry from issue #${ISSUE_NUMBER}"
67-
git push origin "$BRANCH"
67+
git push --force origin "$BRANCH"
6868
PR_BODY=$(printf 'Resolves #%s\n\nAuto-generated from issue by @%s.\n\n**Please review the entry before merging.**' "${ISSUE_NUMBER}" "${ISSUE_AUTHOR}")
69-
gh pr create \
70-
--title "Add entry: ${ISSUE_TITLE}" \
71-
--body "$PR_BODY" \
72-
--head "$BRANCH" \
73-
--base main \
74-
--label "review-needed"
69+
EXISTING_PR=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty')
70+
if [ -z "$EXISTING_PR" ]; then
71+
gh pr create \
72+
--title "Add entry: ${ISSUE_TITLE}" \
73+
--body "$PR_BODY" \
74+
--head "$BRANCH" \
75+
--base main
76+
else
77+
echo "PR #${EXISTING_PR} already exists for this branch — skipping creation"
78+
fi
7579
7680
- name: Comment on issue
7781
env:

0 commit comments

Comments
 (0)