Skip to content
Merged
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
27 changes: 15 additions & 12 deletions .github/workflows/staging-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,29 @@ jobs:
const repo = context.repo.repo
const sha = context.sha

// Check if the commit message indicates a PR merge
const { data: commit } = await github.rest.repos.getCommit({
owner,
repo,
ref: sha
})

const isMergeCommit = commit.commit.message.match(/^Merge pull request #(\d+)/)

// Also check via API for associated PRs
// Check via API for associated PRs merged into staging
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner,
repo,
commit_sha: sha,
per_page: 100
})

const mergedIntoStaging = prs.some((pr) =>
const mergedPRIntoStaging = prs.some((pr) =>
pr.merged_at && pr.base && pr.base.ref === 'staging'
) || (isMergeCommit && commit.parents.length > 1)
)

// Also check commit message for merge commit pattern
const { data: commit } = await github.rest.repos.getCommit({
owner,
repo,
ref: sha
})

const isMergeCommit = commit.commit.message.match(/^Merge pull request #(\d+)/) &&
commit.parents.length > 1

const mergedIntoStaging = mergedPRIntoStaging || isMergeCommit

core.setOutput('merged_pr', mergedIntoStaging ? 'true' : 'false')
if (!mergedIntoStaging) {
Expand Down