File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { getOctokit } from '@actions/github'
2+ const token = process . env . GITHUB_TOKEN
3+ const prNumber = process . env . AUTOMERGE_PR_NUMBER
4+ const github = getOctokit ( token )
5+
6+ main ( )
7+ async function main ( ) {
8+ const pull = await github . pulls . get ( {
9+ ...context . repo ,
10+ pull_number : parseInt ( prNumber ) ,
11+ } )
12+
13+ const pullNodeId = pull . data . node_id
14+ console . log ( `Pull request GraphQL Node ID: ${ pullNodeId } ` )
15+
16+ const mutation = `mutation ($id: ID!) {
17+ enablePullRequestAutoMerge(input: {
18+ pullRequestId: $id,
19+ mergeMethod: MERGE
20+ }) {
21+ clientMutationId
22+ }
23+ }`
24+ const variables = {
25+ id : pullNodeId ,
26+ }
27+
28+ const graph = await github . graphql ( mutation , variables )
29+ console . log ( 'GraphQL mutation result:\n' + JSON . stringify ( graph ) )
30+
31+ if ( graph . errors && graph . errors . length > 0 ) {
32+ console . error (
33+ 'ERROR! Failed to enable auto-merge:\n - ' +
34+ graph . errors . map ( ( error ) => error . message ) . join ( '\n - ' )
35+ )
36+ } else {
37+ console . log ( 'Auto-merge enabled!' )
38+ }
39+ }
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ export default [
2626 'juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51' , // v1.5.0
2727 'juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512' ,
2828 'lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb' ,
29- 'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07' , // v0.12.0
3029 'peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e' ,
3130 'peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd' ,
3231 'peter-evans/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad' , // v3.10.1
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -64,10 +64,16 @@ jobs:
6464 " Hello! The GitHub Enterprise Server release dates have changed.\n\n
6565 If CI passes, this PR will be auto-merged. :green_heart:\n\n
6666 If CI does not pass or other problems arise, contact #docs-engineering on slack.\n\n This PR was 🤖-crafted by `.github/workflows/enterprise-dates.yml`. 🧶"
67- labels : automerge, autoupdate
67+ labels : autoupdate
6868 branch : enterprise-server-dates-update
6969 delete-branch : true
7070
71+ - name : Enable GitHub auto-merge
72+ if : ${{ steps.create-pull-request.outputs.pull-request-number }}
73+ env :
74+ AUTOMERGE_PR_NUMBER : ${{ steps.create-pull-request.outputs.pull-request-number }}
75+ run : node .github/actions-scripts/enable-automerge.js
76+
7177 - if : ${{ failure() && env.FREEZE != 'true' }}
7278 name : Delete remote branch (if previous steps failed)
7379 uses : dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
Original file line number Diff line number Diff line change @@ -216,38 +216,9 @@ jobs:
216216
217217 - name : Enable GitHub auto-merge
218218 if : ${{ steps.find-pull-request.outputs.number }}
219- uses : actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
220- with :
221- github-token : ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
222- script : |
223- const pull = await github.pulls.get({
224- ...context.repo,
225- pull_number: parseInt(${{ steps.find-pull-request.outputs.number }})
226- })
227-
228- const pullNodeId = pull.data.node_id
229- console.log(`Pull request GraphQL Node ID: ${pullNodeId}`)
230-
231- const mutation = `mutation ($id: ID!) {
232- enablePullRequestAutoMerge(input: {
233- pullRequestId: $id,
234- mergeMethod: MERGE
235- }) {
236- clientMutationId
237- }
238- }`
239- const variables = {
240- id: pullNodeId
241- }
242-
243- const graph = await github.graphql(mutation, variables)
244- console.log('GraphQL mutation result:\n' + JSON.stringify(graph))
245-
246- if (graph.errors && graph.errors.length > 0) {
247- console.error('ERROR! Failed to enable auto-merge:\n - ' + graph.errors.map(error => error.message).join('\n - '))
248- } else {
249- console.log('Auto-merge enabled!')
250- }
219+ env :
220+ AUTOMERGE_PR_NUMBER : ${{ steps.find-pull-request.outputs.number }}
221+ run : node .github/actions-scripts/enable-automerge.js
251222
252223 - name : Send Slack notification if workflow fails
253224 uses : someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5858 syncs up the GraphQL data in this repo.\n\n
5959 If CI passes, this PR will be auto-merged. :green_heart:\n\n
6060 If CI does not pass or other problems arise, contact #docs-engineering on slack."
61- labels : automerge, autoupdate
61+ labels : autoupdate
6262 branch : graphql-schema-update
6363
64+ - name : Enable GitHub auto-merge
65+ if : ${{ steps.create-pull-request.outputs.pull-request-number }}
66+ env :
67+ AUTOMERGE_PR_NUMBER : ${{ steps.create-pull-request.outputs.pull-request-number }}
68+ run : node .github/actions-scripts/enable-automerge.js
69+
6470 - if : ${{ failure() && env.FREEZE != 'true'}}
6571 name : Delete remote branch (if previous steps failed)
6672 uses : dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
You can’t perform that action at this time.
0 commit comments