Skip to content

Commit 548ef31

Browse files
authored
Enable auto-merge as Octomerger (#18709)
* Use Octomerger PAT for updating branch and enabling auto-merge * Tweak debugging output for GraphQL mutation
1 parent aa08731 commit 548ef31

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

.github/workflows/repo-sync.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
if: ${{ steps.find-pull-request.outputs.number }}
140140
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
141141
with:
142-
github-token: ${{ secrets.GITHUB_TOKEN }}
142+
github-token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
143143
script: |
144144
const mainHeadSha = await github.git.getRef({
145145
...context.repo,
@@ -167,14 +167,16 @@ jobs:
167167
if: ${{ steps.find-pull-request.outputs.number }}
168168
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
169169
with:
170-
github-token: ${{ secrets.GITHUB_TOKEN }}
170+
github-token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
171171
script: |
172172
const pull = await github.pulls.get({
173173
...context.repo,
174174
pull_number: parseInt(${{ steps.find-pull-request.outputs.number }})
175175
})
176+
176177
const pullNodeId = pull.data.node_id
177178
console.log(`Pull request GraphQL Node ID: ${pullNodeId}`)
179+
178180
const mutation = `mutation ($id: ID!) {
179181
enablePullRequestAutoMerge(input: {
180182
pullRequestId: $id,
@@ -186,9 +188,12 @@ jobs:
186188
const variables = {
187189
id: pullNodeId
188190
}
191+
189192
const graph = await github.graphql(mutation, variables)
193+
console.log('GraphQL mutation result:\n' + JSON.stringify(graph))
194+
190195
if (graph.errors && graph.errors.length > 0) {
191-
console.error('ERROR! Failed to enable auto-merge:\n - ', graph.errors.map(error => error.message).join('\n - '))
196+
console.error('ERROR! Failed to enable auto-merge:\n - ' + graph.errors.map(error => error.message).join('\n - '))
192197
} else {
193198
console.log('Auto-merge enabled!')
194199
}

0 commit comments

Comments
 (0)