File tree 1 file changed +33
-2
lines changed
1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 59
59
}`
60
60
const data = {
61
61
pullRequestId: response.repository.pullRequest.id,
62
- mergeMethod: 'MERGE ',
62
+ mergeMethod: 'SQUASH ',
63
63
}
64
64
65
- await github.graphql(enableAutoMergeQuery, data)
65
+ const checkStatusQuery = `query($owner: String!, $repo: String!, $pullRequestNumber: Int!) {
66
+ repository(owner: $owner, name: $repo) {
67
+ pullRequest(number: $pullRequestNumber) {
68
+ commits(last: 1) {
69
+ nodes {
70
+ commit {
71
+ statusCheckRollup {
72
+ state
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }`
80
+
81
+ // Check if status checks are successful
82
+ const statusResponse = await github.graphql(checkStatusQuery, repoInfo)
83
+ const checkState = statusResponse.repository.pullRequest.commits.nodes[0]?.commit?.statusCheckRollup?.state
84
+
85
+ if (checkState !== 'SUCCESS') {
86
+ console.log('Status checks are not successful yet. Current state:', checkState)
87
+ core.setFailed('Status checks must pass before enabling auto-merge')
88
+ return
89
+ }
90
+
91
+ try {
92
+ await github.graphql(enableAutoMergeQuery, data)
93
+ } catch (error) {
94
+ console.log('Failed to enable auto-merge:', error.message)
95
+ core.setFailed(error.message)
96
+ }
You can’t perform that action at this time.
0 commit comments