Skip to content

Commit

Permalink
dependabot auto merge fix: use squash instead of merge, check status … (
Browse files Browse the repository at this point in the history
#12859)

Use squash instead of merge, check status first to avoid unstable
status, add error logging
  • Loading branch information
kyledurand authored Nov 1, 2024
1 parent f1e3d3d commit 1e0f461
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,38 @@ jobs:
}`
const data = {
pullRequestId: response.repository.pullRequest.id,
mergeMethod: 'MERGE',
mergeMethod: 'SQUASH',
}
await github.graphql(enableAutoMergeQuery, data)
const checkStatusQuery = `query($owner: String!, $repo: String!, $pullRequestNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pullRequestNumber) {
commits(last: 1) {
nodes {
commit {
statusCheckRollup {
state
}
}
}
}
}
}
}`
// Check if status checks are successful
const statusResponse = await github.graphql(checkStatusQuery, repoInfo)
const checkState = statusResponse.repository.pullRequest.commits.nodes[0]?.commit?.statusCheckRollup?.state
if (checkState !== 'SUCCESS') {
console.log('Status checks are not successful yet. Current state:', checkState)
core.setFailed('Status checks must pass before enabling auto-merge')
return
}
try {
await github.graphql(enableAutoMergeQuery, data)
} catch (error) {
console.log('Failed to enable auto-merge:', error.message)
core.setFailed(error.message)
}

0 comments on commit 1e0f461

Please sign in to comment.