Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/pr-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,24 @@ jobs:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
PR_BRANCH=${{ github.event.pull_request.base.ref }}

PR_NUMBER=${PR_BRANCH#main-pr}

# Use GitHub's API to get issues referenced with closing keywords
CLOSING_ISSUES=$(gh pr view "$PR_NUMBER" --json closingIssuesReferences \
--jq '.closingIssuesReferences[].number' || true)

BODY="This PR was automatically created by GitHub Actions to merge changes from $PR_BRANCH into main."
if [ -n "$CLOSING_ISSUES" ]; then
while IFS= read -r issue; do
BODY="$BODY"$'\n'"Closes #$issue"
done <<< "$CLOSING_ISSUES"
fi

# Create the pull request
PR_URL=$(gh pr create \
--head "$PR_BRANCH" \
--base main \
--title "Merge External PR: Merge $PR_BRANCH into main" \
--body "This PR was automatically created by GitHub Actions to merge changes from $PR_BRANCH into main.")
--body "$BODY")

gh pr merge "$PR_URL" --rebase --admin --delete-branch