-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of Github auto-merge action
- Loading branch information
0 parents
commit 9980046
Showing
8 changed files
with
9,350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: 'Enable Github Automerge' | ||
description: 'Enable Github auto-merge for specific pull-requests' | ||
branding: | ||
icon: 'git-merge' | ||
color: 'green' | ||
inputs: | ||
github-token: | ||
description: 'The GITHUB_TOKEN secret' | ||
required: true | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "enable-github-automerge-action", | ||
"version": "0.0.0-alpha.1", | ||
"description": "", | ||
"main": "dist/main.ts", | ||
"scripts": { | ||
"build": "ncc build src/main.ts", | ||
"format": "prettier --write **/*.ts", | ||
"format-check": "prettier --check **/*.ts" | ||
}, | ||
"author": "Alex Wilson <[email protected]>", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/node": "^14.14.25", | ||
"@vercel/ncc": "^0.27.0", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.1.3" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "^1.2.6", | ||
"@actions/github": "^4.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as core from "@actions/core"; | ||
import * as github from "@actions/github"; | ||
|
||
async function run() { | ||
try { | ||
const token = core.getInput("github-token", { required: true }); | ||
const client = github.getOctokit(token); | ||
|
||
const { pull_request: pullRequest } = github.context.payload; | ||
if (!pullRequest) { | ||
throw new Error("Event payload missing `pull_request`"); | ||
} | ||
|
||
core.debug(`Enabling auto-merge for pull-request #${pullRequest.number}`); | ||
client.graphql(` | ||
mutation { | ||
enablePullRequestAutoMerge(input:{ | ||
pullRequestId: "${pullRequest.node_id}" | ||
}) { | ||
clientMutationId | ||
pullRequest { | ||
id | ||
state | ||
} | ||
} | ||
} | ||
`); | ||
core.debug( | ||
`Successfully enabled auto-merge for pull-request #${pullRequest.number}` | ||
); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "commonjs", | ||
"outDir": "./lib", | ||
"rootDir": "./src", | ||
"strict": true, | ||
"noImplicitAny": false, | ||
"esModuleInterop": true | ||
}, | ||
"exclude": ["node_modules", "**/*.test.ts"] | ||
} | ||
|