Skip to content
Closed
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: 13 additions & 3 deletions .github/workflows/merge-approved-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
required: true
type: string
description: 'Regex pattern for the required head branch (e.g., ^stable-main-[0-9]+\.[0-9]+\.[0-9]+$)'
merge-method:
required: false
type: string
default: 'merge'
description: "Merge method: 'merge' (merge commit) or 'squash' (squash merge)"
secrets:
github-token:
required: true
Expand All @@ -35,7 +40,12 @@ jobs:
echo "::error::Missing required input: 'head-branch-pattern' must be provided."
exit 1
fi
echo "Inputs validated: required-base-branch='${{ inputs.required-base-branch }}', head-branch-pattern='${{ inputs.head-branch-pattern }}'"
MERGE_METHOD="${{ inputs.merge-method }}"
if [[ "$MERGE_METHOD" != "merge" && "$MERGE_METHOD" != "squash" ]]; then
echo "::error::Invalid input: 'merge-method' must be either 'merge' or 'squash'. Got '$MERGE_METHOD'."
exit 1
fi
echo "Inputs validated: required-base-branch='${{ inputs.required-base-branch }}', head-branch-pattern='${{ inputs.head-branch-pattern }}', merge-method='$MERGE_METHOD'"

# Fetch PR metadata (head and base branches) using the GitHub API
- name: Get PR Details
Expand Down Expand Up @@ -146,12 +156,12 @@ jobs:
github-token: ${{ secrets.github-token }}
script: |
try {
// Perform the merge using the 'merge' method (creates a merge commit, does not squash)
// Perform the merge using the requested method ('merge' or 'squash')
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ inputs.pr-number }},
merge_method: 'merge'
merge_method: '${{ inputs.merge-method }}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be provided as environment variable (as well as the PR number, though not strictly related to this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, actually I'm going to close this PR, we're going with a different solution to this issue

});
console.log(`PR merged successfully: Source '${process.env.HEAD_REF}' -> Target '${process.env.BASE_REF}'.`);
} catch (error) {
Expand Down
Loading