Skip to content

Commit 44b1204

Browse files
authored
fix: improve pr detection (#62)
* chore: update pnpm lockfile * chore: revert test changes * fix: add packages field to cms pnpm-workspace.yaml * test: workflow changes * fix: allow sync-mdx to run from staging branch * test: trigger sync-mdx job * ci: test mdx change * fix: improve PR detection to prioritize API check * ci: tweak to test
1 parent 5a2545f commit 44b1204

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/staging-merge.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,29 @@ jobs:
4646
const repo = context.repo.repo
4747
const sha = context.sha
4848
49-
// Check if the commit message indicates a PR merge
50-
const { data: commit } = await github.rest.repos.getCommit({
51-
owner,
52-
repo,
53-
ref: sha
54-
})
55-
56-
const isMergeCommit = commit.commit.message.match(/^Merge pull request #(\d+)/)
57-
58-
// Also check via API for associated PRs
49+
// Check via API for associated PRs merged into staging
5950
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
6051
owner,
6152
repo,
6253
commit_sha: sha,
6354
per_page: 100
6455
})
6556
66-
const mergedIntoStaging = prs.some((pr) =>
57+
const mergedPRIntoStaging = prs.some((pr) =>
6758
pr.merged_at && pr.base && pr.base.ref === 'staging'
68-
) || (isMergeCommit && commit.parents.length > 1)
59+
)
60+
61+
// Also check commit message for merge commit pattern
62+
const { data: commit } = await github.rest.repos.getCommit({
63+
owner,
64+
repo,
65+
ref: sha
66+
})
67+
68+
const isMergeCommit = commit.commit.message.match(/^Merge pull request #(\d+)/) &&
69+
commit.parents.length > 1
70+
71+
const mergedIntoStaging = mergedPRIntoStaging || isMergeCommit
6972
7073
core.setOutput('merged_pr', mergedIntoStaging ? 'true' : 'false')
7174
if (!mergedIntoStaging) {

0 commit comments

Comments
 (0)