├── .github ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── auto-merge-dependabot.yml │ ├── rebuild.yml │ └── test.yml ├── .gitignore ├── .nvmrc ├── LICENSE.md ├── README.md ├── action.yml ├── dist └── index.js ├── package-lock.json ├── package.json ├── src ├── enable-github-automerge-action.ts ├── local.ts └── main.ts ├── stub └── example-pull-request.json └── tsconfig.json /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | versioning-strategy: increase-if-necessary 9 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Why? 2 | _What is this trying to achieve? What kind of change is this?_ 3 | 4 | # What? 5 | _What changes have you made? What was your thought process?_ 6 | 7 | # Anything else? 8 | _Any other relevant information you'd like to include?_ -------------------------------------------------------------------------------- /.github/workflows/auto-merge-dependabot.yml: -------------------------------------------------------------------------------- 1 | name: Automatically Update Dependencies 2 | 3 | # `pull_request_target` grants access to secrets and runs in the scope of the *destination* branch. 4 | # Specifically we listen for the labelled event. 5 | on: 6 | pull_request_target: 7 | types: [labeled] 8 | 9 | jobs: 10 | # Explicitly check-out & run a local version of this action. 11 | # Note: This is *not* a recommended practice, and is only done here to dogfood the action. 12 | # Please avoid running this action in a workflow which checks out code. 13 | auto-merge-dependency-updates: 14 | name: Enable auto-merge for Dependabot PRs 15 | runs-on: ubuntu-latest 16 | # Specifically check the creator of the pull-request, not the actor. 17 | if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@main 21 | with: 22 | fetch-depth: 1 23 | - id: enable-automerge 24 | name: Enable Github Automerge 25 | uses: ./ 26 | with: 27 | github-token: "${{ secrets.ENABLE_AUTOMERGE_ACTION_TOKEN }}" 28 | 29 | # Reference hmarr/auto-approve-action by commit SHA as it is an immutable reference to a 30 | # known, "trusted" version of this 3rd party code. 31 | # Note: This is a separate job to explicitly *not* check-out local code. 32 | auto-approve-dependency-updates: 33 | name: Approve dependabot PRs 34 | runs-on: ubuntu-latest 35 | needs: auto-merge-dependency-updates 36 | # Specifically check the creator of the pull-request, not the actor. 37 | if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') 38 | steps: 39 | - id: auto-approve-dependabot 40 | uses: hmarr/auto-approve-action@8f929096a962e83ccdfa8afcf855f39f12d4dac7 41 | with: 42 | github-token: "${{ secrets.GITHUB_TOKEN }}" 43 | -------------------------------------------------------------------------------- /.github/workflows/rebuild.yml: -------------------------------------------------------------------------------- 1 | # Always rebuild the distributable action, so that we can release from `main` at any point 2 | # This doubles-up as a test, and also prevents tampering! 3 | 4 | name: Rebuild 5 | on: 6 | push: 7 | branches-ignore: 8 | - main 9 | 10 | jobs: 11 | rebuild: 12 | name: Build 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@main 17 | with: 18 | fetch-depth: 1 19 | - uses: actions/setup-node@main 20 | with: 21 | node-version-file: ".nvmrc" 22 | - name: Install Dependencies 23 | run: npm ci --ignore-scripts 24 | - name: Build 25 | run: npm run build 26 | - uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d 27 | with: 28 | file_pattern: --force dist/* 29 | commit_message: "chore: 🛠 Rebuild action!" 30 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # Attempt to lint & build the action. 2 | # We *separately* rebuild the action, this build is used as a status check. 3 | name: Test 4 | on: 5 | pull_request: 6 | schedule: 7 | # Scheduled build so failures are noticed quicker. 8 | - cron: "17 4 * * 2,5" 9 | 10 | jobs: 11 | # Lint & build 12 | test: 13 | name: Test 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@main 18 | with: 19 | fetch-depth: 1 20 | - uses: actions/setup-node@main 21 | with: 22 | node-version-file: ".nvmrc" 23 | - name: Install Dependencies 24 | run: npm ci --ignore-scripts 25 | - name: Lint 26 | run: npm run format-check 27 | - name: Build 28 | run: npm run build 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v20 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2021 Alex Wilson 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Enable Github Auto-Merge Action 2 | 3 | > Speed up your workflows by automatically enabling Auto-Merge in your Github pull-requests, so you can release when ready. 4 | 5 | [![Public workflows that use this action](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dalexwilson%2Fenable-github-automerge-action%26badge%3Dtrue)](https://github.com/search?o=desc&q=alexwilson%2Fenable-github-automerge-action+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code) 6 | [![CI status](https://github.com/alexwilson/enable-github-automerge-action/workflows/Test/badge.svg)](https://github.com/alexwilson/enable-github-automerge-action/actions?query=workflow%Test) 7 | 8 | 9 | Name: `alexwilson/enable-github-automerge-action` 10 | 11 | ## 1) What is this? 12 | 13 | To speed up some of your workflows, this action allows you to automatically enable [Auto-Merge](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/automatically-merging-a-pull-request) in your Github pull-requests. 14 | 15 | When enabled, auto-merge will merge pull-requests automatically _as soon as all requirements are met_ (i.e. approvals, passing tests). 16 | 17 | _You can use this, for example, to automatically merge Dependabot pull-requests_. 18 | 19 | This action pairs well with [`hmarr/auto-approve-action`](https://github.com/hmarr/auto-approve-action). 20 | 21 | ## 2) Usage 22 | 23 | Add as a step inside a GitHub workflow, e.g. `.github/workflows/auto-merge.yml`. [You can see an example of this in this repository](./.github/workflows/auto-merge-dependabot.yml). 24 | 25 | > ⚠️ GitHub have [recently improved the security model of actions](https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/) reducing the risk of unknown code accessing secrets, so we recommend running this in an isolated workflow within the `pull_request_target` scope, on a trusted event (e.g. `labeled`). 26 | 27 | ```yaml 28 | name: Auto-Merge 29 | on: 30 | pull_request_target: 31 | types: [labeled] 32 | 33 | jobs: 34 | enable-auto-merge: 35 | runs-on: ubuntu-latest 36 | 37 | # Specifically check that dependabot (or another trusted party) created this pull-request, and that it has been labelled correctly. 38 | if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') 39 | steps: 40 | - uses: alexwilson/enable-github-automerge-action@main 41 | with: 42 | github-token: "${{ secrets.GITHUB_TOKEN }}" 43 | ``` 44 | 45 | *Note*: You will probably want to add some restrictions so this doesn't auto-merge every PR: these are handled fairly well by GitHub Workflow syntax, [you can read more about this here](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsif). 46 | 47 | ### 2.1) Additional Options 48 | 49 | ```yaml 50 | - uses: alexwilson/enable-github-automerge-action@1.0.0 51 | with: 52 | github-token: "${{ secrets.GITHUB_TOKEN }}" 53 | merge-method: "SQUASH" 54 | ``` 55 | 56 | - **github-token**: The Github Token to use for this action. By default this variable is set to run as `github-actions`, however you can replace this with another user/actor's Github Token (make sure it has, _at minimum_, `repo` scope). 57 | - **merge-method**: Override the merge method. By default this action attempts to select your repository's default merge method, and falls back to merge. One of `MERGE`, `SQUASH` or `REBASE`. [Read more here](https://docs.github.com/en/graphql/reference/enums#pullrequestmergemethod). 58 | 59 | ## 3) Developing Locally 60 | 61 | Github Action developer-experience isn't fantastic, so for now we mimic the Github Action environment in `./src/local.ts`. 62 | 63 | This file sets environment variables locally to enable action inputs, and points to a sample pull-request webhook event in `./stub/example-pull-request.json`. 64 | 65 | 1. Make sure you're running a recent version of Node (the correct version will always be in `.nvmrc` and `action.yml`) 66 | 2. Set `GITHUB_TOKEN` locally. (You can do this via `$ export GITHUB_TOKEN=blah`) 67 | 3. Optionally(!) set `MERGE_METHOD` locally. (You can do this via `$ export MERGE_METHOD=MERGE`) 68 | 4. Run with `npm run local`. 69 | 5. **Important**: Avoid committing anything to `dist/*` — this is automatically regenerated and manually adjusting this will make rebasing harder! 70 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Enable Github Automerge" 2 | description: "Enable Github auto-merge for specific pull-requests" 3 | branding: 4 | icon: "git-merge" 5 | color: "green" 6 | inputs: 7 | github-token: 8 | description: "The GITHUB_TOKEN secret" 9 | required: true 10 | merge-method: 11 | description: "Preferred merge method for automatic merges." 12 | required: false 13 | runs: 14 | using: "node20" 15 | main: "dist/index.js" 16 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enable-github-automerge-action", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "enable-github-automerge-action", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@actions/core": "^1.10.1", 13 | "@actions/github": "^6.0.0" 14 | }, 15 | "devDependencies": { 16 | "@types/node": "^24.0.0", 17 | "@vercel/ncc": "^0.38.1", 18 | "prettier": "^3.2.5", 19 | "ts-node": "^10.9.2", 20 | "typescript": "^5.3.3" 21 | } 22 | }, 23 | "node_modules/@actions/core": { 24 | "version": "1.11.1", 25 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz", 26 | "integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==", 27 | "dependencies": { 28 | "@actions/exec": "^1.1.1", 29 | "@actions/http-client": "^2.0.1" 30 | } 31 | }, 32 | "node_modules/@actions/exec": { 33 | "version": "1.1.1", 34 | "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", 35 | "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", 36 | "dependencies": { 37 | "@actions/io": "^1.0.1" 38 | } 39 | }, 40 | "node_modules/@actions/github": { 41 | "version": "6.0.1", 42 | "resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.1.tgz", 43 | "integrity": "sha512-xbZVcaqD4XnQAe35qSQqskb3SqIAfRyLBrHMd/8TuL7hJSz2QtbDwnNM8zWx4zO5l2fnGtseNE3MbEvD7BxVMw==", 44 | "license": "MIT", 45 | "dependencies": { 46 | "@actions/http-client": "^2.2.0", 47 | "@octokit/core": "^5.0.1", 48 | "@octokit/plugin-paginate-rest": "^9.2.2", 49 | "@octokit/plugin-rest-endpoint-methods": "^10.4.0", 50 | "@octokit/request": "^8.4.1", 51 | "@octokit/request-error": "^5.1.1", 52 | "undici": "^5.28.5" 53 | } 54 | }, 55 | "node_modules/@actions/http-client": { 56 | "version": "2.2.0", 57 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz", 58 | "integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==", 59 | "dependencies": { 60 | "tunnel": "^0.0.6", 61 | "undici": "^5.25.4" 62 | } 63 | }, 64 | "node_modules/@actions/io": { 65 | "version": "1.1.3", 66 | "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", 67 | "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" 68 | }, 69 | "node_modules/@cspotcode/source-map-support": { 70 | "version": "0.8.1", 71 | "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", 72 | "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", 73 | "dev": true, 74 | "dependencies": { 75 | "@jridgewell/trace-mapping": "0.3.9" 76 | }, 77 | "engines": { 78 | "node": ">=12" 79 | } 80 | }, 81 | "node_modules/@fastify/busboy": { 82 | "version": "2.1.0", 83 | "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", 84 | "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", 85 | "engines": { 86 | "node": ">=14" 87 | } 88 | }, 89 | "node_modules/@jridgewell/resolve-uri": { 90 | "version": "3.1.2", 91 | "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", 92 | "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", 93 | "dev": true, 94 | "engines": { 95 | "node": ">=6.0.0" 96 | } 97 | }, 98 | "node_modules/@jridgewell/sourcemap-codec": { 99 | "version": "1.4.15", 100 | "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", 101 | "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", 102 | "dev": true 103 | }, 104 | "node_modules/@jridgewell/trace-mapping": { 105 | "version": "0.3.9", 106 | "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", 107 | "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", 108 | "dev": true, 109 | "dependencies": { 110 | "@jridgewell/resolve-uri": "^3.0.3", 111 | "@jridgewell/sourcemap-codec": "^1.4.10" 112 | } 113 | }, 114 | "node_modules/@octokit/auth-token": { 115 | "version": "4.0.0", 116 | "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", 117 | "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", 118 | "engines": { 119 | "node": ">= 18" 120 | } 121 | }, 122 | "node_modules/@octokit/core": { 123 | "version": "5.1.0", 124 | "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.1.0.tgz", 125 | "integrity": "sha512-BDa2VAMLSh3otEiaMJ/3Y36GU4qf6GI+VivQ/P41NC6GHcdxpKlqV0ikSZ5gdQsmS3ojXeRx5vasgNTinF0Q4g==", 126 | "dependencies": { 127 | "@octokit/auth-token": "^4.0.0", 128 | "@octokit/graphql": "^7.0.0", 129 | "@octokit/request": "^8.0.2", 130 | "@octokit/request-error": "^5.0.0", 131 | "@octokit/types": "^12.0.0", 132 | "before-after-hook": "^2.2.0", 133 | "universal-user-agent": "^6.0.0" 134 | }, 135 | "engines": { 136 | "node": ">= 18" 137 | } 138 | }, 139 | "node_modules/@octokit/endpoint": { 140 | "version": "9.0.6", 141 | "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.6.tgz", 142 | "integrity": "sha512-H1fNTMA57HbkFESSt3Y9+FBICv+0jFceJFPWDePYlR/iMGrwM5ph+Dd4XRQs+8X+PUFURLQgX9ChPfhJ/1uNQw==", 143 | "license": "MIT", 144 | "dependencies": { 145 | "@octokit/types": "^13.1.0", 146 | "universal-user-agent": "^6.0.0" 147 | }, 148 | "engines": { 149 | "node": ">= 18" 150 | } 151 | }, 152 | "node_modules/@octokit/endpoint/node_modules/@octokit/openapi-types": { 153 | "version": "23.0.1", 154 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz", 155 | "integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==", 156 | "license": "MIT" 157 | }, 158 | "node_modules/@octokit/endpoint/node_modules/@octokit/types": { 159 | "version": "13.8.0", 160 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz", 161 | "integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==", 162 | "license": "MIT", 163 | "dependencies": { 164 | "@octokit/openapi-types": "^23.0.1" 165 | } 166 | }, 167 | "node_modules/@octokit/graphql": { 168 | "version": "7.0.2", 169 | "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", 170 | "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==", 171 | "dependencies": { 172 | "@octokit/request": "^8.0.1", 173 | "@octokit/types": "^12.0.0", 174 | "universal-user-agent": "^6.0.0" 175 | }, 176 | "engines": { 177 | "node": ">= 18" 178 | } 179 | }, 180 | "node_modules/@octokit/openapi-types": { 181 | "version": "20.0.0", 182 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-20.0.0.tgz", 183 | "integrity": "sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA==", 184 | "license": "MIT" 185 | }, 186 | "node_modules/@octokit/plugin-paginate-rest": { 187 | "version": "9.2.2", 188 | "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.2.tgz", 189 | "integrity": "sha512-u3KYkGF7GcZnSD/3UP0S7K5XUFT2FkOQdcfXZGZQPGv3lm4F2Xbf71lvjldr8c1H3nNbF+33cLEkWYbokGWqiQ==", 190 | "license": "MIT", 191 | "dependencies": { 192 | "@octokit/types": "^12.6.0" 193 | }, 194 | "engines": { 195 | "node": ">= 18" 196 | }, 197 | "peerDependencies": { 198 | "@octokit/core": "5" 199 | } 200 | }, 201 | "node_modules/@octokit/plugin-rest-endpoint-methods": { 202 | "version": "10.4.1", 203 | "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz", 204 | "integrity": "sha512-xV1b+ceKV9KytQe3zCVqjg+8GTGfDYwaT1ATU5isiUyVtlVAO3HNdzpS4sr4GBx4hxQ46s7ITtZrAsxG22+rVg==", 205 | "license": "MIT", 206 | "dependencies": { 207 | "@octokit/types": "^12.6.0" 208 | }, 209 | "engines": { 210 | "node": ">= 18" 211 | }, 212 | "peerDependencies": { 213 | "@octokit/core": "5" 214 | } 215 | }, 216 | "node_modules/@octokit/request": { 217 | "version": "8.4.1", 218 | "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.4.1.tgz", 219 | "integrity": "sha512-qnB2+SY3hkCmBxZsR/MPCybNmbJe4KAlfWErXq+rBKkQJlbjdJeS85VI9r8UqeLYLvnAenU8Q1okM/0MBsAGXw==", 220 | "license": "MIT", 221 | "dependencies": { 222 | "@octokit/endpoint": "^9.0.6", 223 | "@octokit/request-error": "^5.1.1", 224 | "@octokit/types": "^13.1.0", 225 | "universal-user-agent": "^6.0.0" 226 | }, 227 | "engines": { 228 | "node": ">= 18" 229 | } 230 | }, 231 | "node_modules/@octokit/request-error": { 232 | "version": "5.1.1", 233 | "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.1.1.tgz", 234 | "integrity": "sha512-v9iyEQJH6ZntoENr9/yXxjuezh4My67CBSu9r6Ve/05Iu5gNgnisNWOsoJHTP6k0Rr0+HQIpnH+kyammu90q/g==", 235 | "license": "MIT", 236 | "dependencies": { 237 | "@octokit/types": "^13.1.0", 238 | "deprecation": "^2.0.0", 239 | "once": "^1.4.0" 240 | }, 241 | "engines": { 242 | "node": ">= 18" 243 | } 244 | }, 245 | "node_modules/@octokit/request-error/node_modules/@octokit/openapi-types": { 246 | "version": "23.0.1", 247 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz", 248 | "integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==", 249 | "license": "MIT" 250 | }, 251 | "node_modules/@octokit/request-error/node_modules/@octokit/types": { 252 | "version": "13.8.0", 253 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz", 254 | "integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==", 255 | "license": "MIT", 256 | "dependencies": { 257 | "@octokit/openapi-types": "^23.0.1" 258 | } 259 | }, 260 | "node_modules/@octokit/request/node_modules/@octokit/openapi-types": { 261 | "version": "23.0.1", 262 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz", 263 | "integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==", 264 | "license": "MIT" 265 | }, 266 | "node_modules/@octokit/request/node_modules/@octokit/types": { 267 | "version": "13.8.0", 268 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz", 269 | "integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==", 270 | "license": "MIT", 271 | "dependencies": { 272 | "@octokit/openapi-types": "^23.0.1" 273 | } 274 | }, 275 | "node_modules/@octokit/types": { 276 | "version": "12.6.0", 277 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.6.0.tgz", 278 | "integrity": "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==", 279 | "license": "MIT", 280 | "dependencies": { 281 | "@octokit/openapi-types": "^20.0.0" 282 | } 283 | }, 284 | "node_modules/@tsconfig/node10": { 285 | "version": "1.0.9", 286 | "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", 287 | "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", 288 | "dev": true 289 | }, 290 | "node_modules/@tsconfig/node12": { 291 | "version": "1.0.11", 292 | "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", 293 | "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", 294 | "dev": true 295 | }, 296 | "node_modules/@tsconfig/node14": { 297 | "version": "1.0.3", 298 | "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", 299 | "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", 300 | "dev": true 301 | }, 302 | "node_modules/@tsconfig/node16": { 303 | "version": "1.0.4", 304 | "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", 305 | "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", 306 | "dev": true 307 | }, 308 | "node_modules/@types/node": { 309 | "version": "24.0.0", 310 | "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.0.tgz", 311 | "integrity": "sha512-yZQa2zm87aRVcqDyH5+4Hv9KYgSdgwX1rFnGvpbzMaC7YAljmhBET93TPiTd3ObwTL+gSpIzPKg5BqVxdCvxKg==", 312 | "dev": true, 313 | "license": "MIT", 314 | "dependencies": { 315 | "undici-types": "~7.8.0" 316 | } 317 | }, 318 | "node_modules/@vercel/ncc": { 319 | "version": "0.38.3", 320 | "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.3.tgz", 321 | "integrity": "sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==", 322 | "dev": true, 323 | "bin": { 324 | "ncc": "dist/ncc/cli.js" 325 | } 326 | }, 327 | "node_modules/acorn": { 328 | "version": "8.11.3", 329 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", 330 | "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", 331 | "dev": true, 332 | "bin": { 333 | "acorn": "bin/acorn" 334 | }, 335 | "engines": { 336 | "node": ">=0.4.0" 337 | } 338 | }, 339 | "node_modules/acorn-walk": { 340 | "version": "8.3.2", 341 | "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", 342 | "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", 343 | "dev": true, 344 | "engines": { 345 | "node": ">=0.4.0" 346 | } 347 | }, 348 | "node_modules/arg": { 349 | "version": "4.1.3", 350 | "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", 351 | "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", 352 | "dev": true 353 | }, 354 | "node_modules/before-after-hook": { 355 | "version": "2.2.3", 356 | "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", 357 | "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" 358 | }, 359 | "node_modules/create-require": { 360 | "version": "1.1.1", 361 | "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", 362 | "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", 363 | "dev": true 364 | }, 365 | "node_modules/deprecation": { 366 | "version": "2.3.1", 367 | "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", 368 | "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" 369 | }, 370 | "node_modules/diff": { 371 | "version": "4.0.2", 372 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", 373 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", 374 | "dev": true, 375 | "engines": { 376 | "node": ">=0.3.1" 377 | } 378 | }, 379 | "node_modules/make-error": { 380 | "version": "1.3.6", 381 | "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", 382 | "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", 383 | "dev": true 384 | }, 385 | "node_modules/once": { 386 | "version": "1.4.0", 387 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 388 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 389 | "dependencies": { 390 | "wrappy": "1" 391 | } 392 | }, 393 | "node_modules/prettier": { 394 | "version": "3.5.3", 395 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", 396 | "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", 397 | "dev": true, 398 | "license": "MIT", 399 | "bin": { 400 | "prettier": "bin/prettier.cjs" 401 | }, 402 | "engines": { 403 | "node": ">=14" 404 | }, 405 | "funding": { 406 | "url": "https://github.com/prettier/prettier?sponsor=1" 407 | } 408 | }, 409 | "node_modules/ts-node": { 410 | "version": "10.9.2", 411 | "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", 412 | "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", 413 | "dev": true, 414 | "dependencies": { 415 | "@cspotcode/source-map-support": "^0.8.0", 416 | "@tsconfig/node10": "^1.0.7", 417 | "@tsconfig/node12": "^1.0.7", 418 | "@tsconfig/node14": "^1.0.0", 419 | "@tsconfig/node16": "^1.0.2", 420 | "acorn": "^8.4.1", 421 | "acorn-walk": "^8.1.1", 422 | "arg": "^4.1.0", 423 | "create-require": "^1.1.0", 424 | "diff": "^4.0.1", 425 | "make-error": "^1.1.1", 426 | "v8-compile-cache-lib": "^3.0.1", 427 | "yn": "3.1.1" 428 | }, 429 | "bin": { 430 | "ts-node": "dist/bin.js", 431 | "ts-node-cwd": "dist/bin-cwd.js", 432 | "ts-node-esm": "dist/bin-esm.js", 433 | "ts-node-script": "dist/bin-script.js", 434 | "ts-node-transpile-only": "dist/bin-transpile.js", 435 | "ts-script": "dist/bin-script-deprecated.js" 436 | }, 437 | "peerDependencies": { 438 | "@swc/core": ">=1.2.50", 439 | "@swc/wasm": ">=1.2.50", 440 | "@types/node": "*", 441 | "typescript": ">=2.7" 442 | }, 443 | "peerDependenciesMeta": { 444 | "@swc/core": { 445 | "optional": true 446 | }, 447 | "@swc/wasm": { 448 | "optional": true 449 | } 450 | } 451 | }, 452 | "node_modules/tunnel": { 453 | "version": "0.0.6", 454 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 455 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", 456 | "engines": { 457 | "node": ">=0.6.11 <=0.7.0 || >=0.7.3" 458 | } 459 | }, 460 | "node_modules/typescript": { 461 | "version": "5.8.3", 462 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", 463 | "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", 464 | "dev": true, 465 | "license": "Apache-2.0", 466 | "bin": { 467 | "tsc": "bin/tsc", 468 | "tsserver": "bin/tsserver" 469 | }, 470 | "engines": { 471 | "node": ">=14.17" 472 | } 473 | }, 474 | "node_modules/undici": { 475 | "version": "5.29.0", 476 | "resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz", 477 | "integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==", 478 | "license": "MIT", 479 | "dependencies": { 480 | "@fastify/busboy": "^2.0.0" 481 | }, 482 | "engines": { 483 | "node": ">=14.0" 484 | } 485 | }, 486 | "node_modules/undici-types": { 487 | "version": "7.8.0", 488 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz", 489 | "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==", 490 | "dev": true, 491 | "license": "MIT" 492 | }, 493 | "node_modules/universal-user-agent": { 494 | "version": "6.0.1", 495 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", 496 | "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==" 497 | }, 498 | "node_modules/v8-compile-cache-lib": { 499 | "version": "3.0.1", 500 | "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", 501 | "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", 502 | "dev": true 503 | }, 504 | "node_modules/wrappy": { 505 | "version": "1.0.2", 506 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 507 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" 508 | }, 509 | "node_modules/yn": { 510 | "version": "3.1.1", 511 | "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", 512 | "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", 513 | "dev": true, 514 | "engines": { 515 | "node": ">=6" 516 | } 517 | } 518 | } 519 | } 520 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enable-github-automerge-action", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/main.ts", 6 | "scripts": { 7 | "build": "ncc build src/main.ts", 8 | "format": "prettier --write **/*.ts", 9 | "format-check": "prettier --check **/*.ts", 10 | "local": "ts-node src/local.ts" 11 | }, 12 | "author": "Alex Wilson ", 13 | "license": "ISC", 14 | "devDependencies": { 15 | "@types/node": "^24.0.0", 16 | "@vercel/ncc": "^0.38.1", 17 | "prettier": "^3.2.5", 18 | "ts-node": "^10.9.2", 19 | "typescript": "^5.3.3" 20 | }, 21 | "dependencies": { 22 | "@actions/core": "^1.10.1", 23 | "@actions/github": "^6.0.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/enable-github-automerge-action.ts: -------------------------------------------------------------------------------- 1 | import { info, debug, error } from "@actions/core"; 2 | import type { GitHub } from "@actions/github/lib/utils"; 3 | import type { Context } from "@actions/github/lib/context"; 4 | 5 | type GitHubClient = InstanceType; 6 | 7 | export type Options = { 8 | preferredMergeMethod?: string; 9 | }; 10 | 11 | type EnableAutoMergeResponse = { 12 | mutationId: string | undefined; 13 | pullRequestState: string | undefined; 14 | enabledAt: string | undefined; 15 | enabledBy: string | undefined; 16 | }; 17 | 18 | export class EnableGithubAutomergeAction { 19 | private client: GitHubClient; 20 | 21 | private context: Context; 22 | 23 | private options: Options; 24 | 25 | constructor(client: GitHubClient, context: Context, options: Options) { 26 | this.client = client; 27 | this.context = context; 28 | this.options = options; 29 | } 30 | 31 | async run() { 32 | // Find out where we are! 33 | const { repo } = this.context; 34 | if (!repo) { 35 | throw new Error("Could not find repository!"); 36 | } 37 | 38 | // Make sure this is actually a pull-request! 39 | // We need this to retrieve the pull-request node ID. 40 | const { pull_request: pullRequest } = this.context.payload; 41 | if (!pullRequest) { 42 | throw new Error( 43 | "Event payload missing `pull_request`, is this a pull-request?", 44 | ); 45 | } 46 | const pullRequestId = pullRequest.node_id; 47 | 48 | // 49 | // Step 1. Retrieve the merge method! 50 | debug(`Retrieving merge-method...`); 51 | const mergeMethod = await this.getMergeMethod(repo); 52 | debug(`Successfully retrieved merge-method as: ${mergeMethod}`); 53 | 54 | // 55 | // Step 2. Enable auto-merge. 56 | debug(`Enabling auto-merge for pull-request #${pullRequest.number}...`); 57 | const { enabledBy, enabledAt } = await this.enableAutoMerge( 58 | pullRequestId, 59 | mergeMethod, 60 | ); 61 | info( 62 | `Successfully enabled auto-merge for pull-request #${pullRequest.number} as ${enabledBy} at ${enabledAt}`, 63 | ); 64 | } 65 | 66 | private async getMergeMethod(repo): Promise { 67 | const { preferredMergeMethod } = this.options; 68 | 69 | // Allow users to specify a merge method. 70 | if (preferredMergeMethod && preferredMergeMethod.length > 0) { 71 | return preferredMergeMethod; 72 | } 73 | 74 | // 75 | // Otherwise try and discover one. 76 | // 77 | 78 | // Merge is the default behaviour. 79 | let mergeMethod: string = `MERGE`; 80 | 81 | // Try to discover the repository's default merge method. 82 | try { 83 | const repositorySettings = (await this.client.graphql( 84 | ` 85 | query($repository: String!, $owner: String!) { 86 | repository(name:$repository, owner:$owner) { 87 | viewerDefaultMergeMethod 88 | } 89 | } 90 | `, 91 | { 92 | repository: repo.repo, 93 | owner: repo.owner, 94 | }, 95 | )) as any; 96 | const viewerDefaultMergeMethod = 97 | repositorySettings?.repository?.viewerDefaultMergeMethod || undefined; 98 | 99 | if (viewerDefaultMergeMethod && viewerDefaultMergeMethod.length > 0) { 100 | mergeMethod = viewerDefaultMergeMethod; 101 | } 102 | } catch (err) { 103 | let message = err instanceof Error ? err.message : String(err); 104 | error(`Failed to read default merge method: ${message}`); 105 | } 106 | 107 | return mergeMethod; 108 | } 109 | 110 | private async enableAutoMerge( 111 | pullRequestId: string, 112 | mergeMethod: string, 113 | ): Promise { 114 | const response = (await this.client.graphql( 115 | ` 116 | mutation( 117 | $pullRequestId: ID!, 118 | $mergeMethod: PullRequestMergeMethod! 119 | ) { 120 | enablePullRequestAutoMerge(input: { 121 | pullRequestId: $pullRequestId, 122 | mergeMethod: $mergeMethod 123 | }) { 124 | clientMutationId 125 | pullRequest { 126 | id 127 | state 128 | autoMergeRequest { 129 | enabledAt 130 | enabledBy { 131 | login 132 | } 133 | } 134 | } 135 | } 136 | } 137 | `, 138 | { 139 | pullRequestId, 140 | mergeMethod, 141 | }, 142 | )) as any; 143 | 144 | const enableAutoMergeResponse: EnableAutoMergeResponse = { 145 | mutationId: response?.enablePullRequestAutoMerge?.clientMutationId, 146 | enabledAt: 147 | response?.enablePullRequestAutoMerge?.pullRequest?.autoMergeRequest 148 | ?.enabledAt, 149 | enabledBy: 150 | response?.enablePullRequestAutoMerge?.pullRequest?.autoMergeRequest 151 | ?.enabledBy?.login, 152 | pullRequestState: 153 | response?.enablePullRequestAutoMerge?.pullRequest?.state, 154 | }; 155 | 156 | if ( 157 | !enableAutoMergeResponse.enabledAt && 158 | !enableAutoMergeResponse.enabledBy 159 | ) { 160 | error( 161 | `Failed to enable auto-merge: Received: ${JSON.stringify( 162 | enableAutoMergeResponse, 163 | )}`, 164 | ); 165 | } 166 | 167 | return enableAutoMergeResponse; 168 | } 169 | } 170 | 171 | export default EnableGithubAutomergeAction; 172 | -------------------------------------------------------------------------------- /src/local.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from "path"; 2 | 3 | async function run() { 4 | [ 5 | ["github-token", "GITHUB_TOKEN"], 6 | ["merge-method", "MERGE_METHOD"], 7 | ].forEach(([inputName, envInputVariable]) => { 8 | if (process.env[envInputVariable]) { 9 | process.env[`INPUT_${inputName.replace(/ /g, "_").toUpperCase()}`] = 10 | process.env[envInputVariable]; 11 | } 12 | }); 13 | 14 | process.env[`GITHUB_EVENT_PATH`] = resolve( 15 | __dirname, 16 | "..", 17 | "stub", 18 | "example-pull-request.json", 19 | ); 20 | 21 | require("./main"); 22 | } 23 | 24 | run(); 25 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as github from "@actions/github"; 2 | import { setFailed, getInput } from "@actions/core"; 3 | import { 4 | EnableGithubAutomergeAction, 5 | Options, 6 | } from "./enable-github-automerge-action"; 7 | 8 | export async function run() { 9 | try { 10 | const { context } = github; 11 | const options: Options = Object.create(null); 12 | 13 | const token = getInput("github-token", { required: true }); 14 | const client = github.getOctokit(token); 15 | 16 | const preferredMergeMethod = getInput("merge-method", { required: false }); 17 | if (preferredMergeMethod) { 18 | options.preferredMergeMethod = preferredMergeMethod; 19 | } 20 | 21 | const automergeAction = new EnableGithubAutomergeAction( 22 | client, 23 | context, 24 | options, 25 | ); 26 | await automergeAction.run(); 27 | } catch (error) { 28 | let message = error instanceof Error ? error.message : String(error); 29 | setFailed(message); 30 | } 31 | } 32 | 33 | run(); 34 | -------------------------------------------------------------------------------- /stub/example-pull-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "action": "opened", 3 | "number": 1, 4 | "pull_request": { 5 | "url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/1", 6 | "id": 571943974, 7 | "node_id": "MDExOlB1bGxSZXF1ZXN0NTcxOTQzOTc0", 8 | "html_url": "https://github.com/alexwilson/enable-github-automerge-action/pull/1", 9 | "diff_url": "https://github.com/alexwilson/enable-github-automerge-action/pull/1.diff", 10 | "patch_url": "https://github.com/alexwilson/enable-github-automerge-action/pull/1.patch", 11 | "issue_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/1", 12 | "number": 1, 13 | "state": "closed", 14 | "locked": false, 15 | "title": "Update README.md", 16 | "user": { 17 | "login": "JakeChampion", 18 | "id": 1569131, 19 | "node_id": "MDQ6VXNlcjE1NjkxMzE=", 20 | "avatar_url": "https://avatars.githubusercontent.com/u/1569131?v=4", 21 | "gravatar_id": "", 22 | "url": "https://api.github.com/users/JakeChampion", 23 | "html_url": "https://github.com/JakeChampion", 24 | "followers_url": "https://api.github.com/users/JakeChampion/followers", 25 | "following_url": "https://api.github.com/users/JakeChampion/following{/other_user}", 26 | "gists_url": "https://api.github.com/users/JakeChampion/gists{/gist_id}", 27 | "starred_url": "https://api.github.com/users/JakeChampion/starred{/owner}{/repo}", 28 | "subscriptions_url": "https://api.github.com/users/JakeChampion/subscriptions", 29 | "organizations_url": "https://api.github.com/users/JakeChampion/orgs", 30 | "repos_url": "https://api.github.com/users/JakeChampion/repos", 31 | "events_url": "https://api.github.com/users/JakeChampion/events{/privacy}", 32 | "received_events_url": "https://api.github.com/users/JakeChampion/received_events", 33 | "type": "User", 34 | "site_admin": false 35 | }, 36 | "body": "", 37 | "created_at": "2021-02-11T16:23:06Z", 38 | "updated_at": "2021-02-18T23:55:58Z", 39 | "closed_at": "2021-02-18T23:16:07Z", 40 | "merged_at": "2021-02-18T23:16:07Z", 41 | "merge_commit_sha": "da533c2bb086d1c7ba514cc32488838c12a0508b", 42 | "assignee": null, 43 | "assignees": [], 44 | "requested_reviewers": [], 45 | "requested_teams": [], 46 | "labels": [], 47 | "milestone": null, 48 | "draft": false, 49 | "commits_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/1/commits", 50 | "review_comments_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/1/comments", 51 | "review_comment_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/comments{/number}", 52 | "comments_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/1/comments", 53 | "statuses_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/statuses/b6e6cb9b752a04e870f44df9f493a4b6c2ceefca", 54 | "head": { 55 | "label": "JakeChampion:patch-1", 56 | "ref": "patch-1", 57 | "sha": "b6e6cb9b752a04e870f44df9f493a4b6c2ceefca", 58 | "user": { 59 | "login": "JakeChampion", 60 | "id": 1569131, 61 | "node_id": "MDQ6VXNlcjE1NjkxMzE=", 62 | "avatar_url": "https://avatars.githubusercontent.com/u/1569131?v=4", 63 | "gravatar_id": "", 64 | "url": "https://api.github.com/users/JakeChampion", 65 | "html_url": "https://github.com/JakeChampion", 66 | "followers_url": "https://api.github.com/users/JakeChampion/followers", 67 | "following_url": "https://api.github.com/users/JakeChampion/following{/other_user}", 68 | "gists_url": "https://api.github.com/users/JakeChampion/gists{/gist_id}", 69 | "starred_url": "https://api.github.com/users/JakeChampion/starred{/owner}{/repo}", 70 | "subscriptions_url": "https://api.github.com/users/JakeChampion/subscriptions", 71 | "organizations_url": "https://api.github.com/users/JakeChampion/orgs", 72 | "repos_url": "https://api.github.com/users/JakeChampion/repos", 73 | "events_url": "https://api.github.com/users/JakeChampion/events{/privacy}", 74 | "received_events_url": "https://api.github.com/users/JakeChampion/received_events", 75 | "type": "User", 76 | "site_admin": false 77 | }, 78 | "repo": { 79 | "id": 338082955, 80 | "node_id": "MDEwOlJlcG9zaXRvcnkzMzgwODI5NTU=", 81 | "name": "enable-github-automerge-action", 82 | "full_name": "JakeChampion/enable-github-automerge-action", 83 | "private": false, 84 | "owner": { 85 | "login": "JakeChampion", 86 | "id": 1569131, 87 | "node_id": "MDQ6VXNlcjE1NjkxMzE=", 88 | "avatar_url": "https://avatars.githubusercontent.com/u/1569131?v=4", 89 | "gravatar_id": "", 90 | "url": "https://api.github.com/users/JakeChampion", 91 | "html_url": "https://github.com/JakeChampion", 92 | "followers_url": "https://api.github.com/users/JakeChampion/followers", 93 | "following_url": "https://api.github.com/users/JakeChampion/following{/other_user}", 94 | "gists_url": "https://api.github.com/users/JakeChampion/gists{/gist_id}", 95 | "starred_url": "https://api.github.com/users/JakeChampion/starred{/owner}{/repo}", 96 | "subscriptions_url": "https://api.github.com/users/JakeChampion/subscriptions", 97 | "organizations_url": "https://api.github.com/users/JakeChampion/orgs", 98 | "repos_url": "https://api.github.com/users/JakeChampion/repos", 99 | "events_url": "https://api.github.com/users/JakeChampion/events{/privacy}", 100 | "received_events_url": "https://api.github.com/users/JakeChampion/received_events", 101 | "type": "User", 102 | "site_admin": false 103 | }, 104 | "html_url": "https://github.com/JakeChampion/enable-github-automerge-action", 105 | "description": "An action for enabling Github Automerge on pull-requests.", 106 | "fork": true, 107 | "url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action", 108 | "forks_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/forks", 109 | "keys_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/keys{/key_id}", 110 | "collaborators_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/collaborators{/collaborator}", 111 | "teams_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/teams", 112 | "hooks_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/hooks", 113 | "issue_events_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/issues/events{/number}", 114 | "events_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/events", 115 | "assignees_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/assignees{/user}", 116 | "branches_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/branches{/branch}", 117 | "tags_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/tags", 118 | "blobs_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/git/blobs{/sha}", 119 | "git_tags_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/git/tags{/sha}", 120 | "git_refs_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/git/refs{/sha}", 121 | "trees_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/git/trees{/sha}", 122 | "statuses_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/statuses/{sha}", 123 | "languages_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/languages", 124 | "stargazers_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/stargazers", 125 | "contributors_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/contributors", 126 | "subscribers_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/subscribers", 127 | "subscription_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/subscription", 128 | "commits_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/commits{/sha}", 129 | "git_commits_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/git/commits{/sha}", 130 | "comments_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/comments{/number}", 131 | "issue_comment_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/issues/comments{/number}", 132 | "contents_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/contents/{+path}", 133 | "compare_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/compare/{base}...{head}", 134 | "merges_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/merges", 135 | "archive_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/{archive_format}{/ref}", 136 | "downloads_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/downloads", 137 | "issues_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/issues{/number}", 138 | "pulls_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/pulls{/number}", 139 | "milestones_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/milestones{/number}", 140 | "notifications_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/notifications{?since,all,participating}", 141 | "labels_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/labels{/name}", 142 | "releases_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/releases{/id}", 143 | "deployments_url": "https://api.github.com/repos/JakeChampion/enable-github-automerge-action/deployments", 144 | "created_at": "2021-02-11T16:22:46Z", 145 | "updated_at": "2021-02-11T16:22:47Z", 146 | "pushed_at": "2021-02-18T23:55:58Z", 147 | "git_url": "git://github.com/JakeChampion/enable-github-automerge-action.git", 148 | "ssh_url": "git@github.com:JakeChampion/enable-github-automerge-action.git", 149 | "clone_url": "https://github.com/JakeChampion/enable-github-automerge-action.git", 150 | "svn_url": "https://github.com/JakeChampion/enable-github-automerge-action", 151 | "homepage": null, 152 | "size": 223, 153 | "stargazers_count": 0, 154 | "watchers_count": 0, 155 | "language": null, 156 | "has_issues": false, 157 | "has_projects": true, 158 | "has_downloads": true, 159 | "has_wiki": true, 160 | "has_pages": false, 161 | "forks_count": 0, 162 | "mirror_url": null, 163 | "archived": false, 164 | "disabled": false, 165 | "open_issues_count": 0, 166 | "license": null, 167 | "forks": 0, 168 | "open_issues": 0, 169 | "watchers": 0, 170 | "default_branch": "main" 171 | } 172 | }, 173 | "base": { 174 | "label": "alexwilson:main", 175 | "ref": "main", 176 | "sha": "c109a3494700181c5f0e488c3f109069db8c9503", 177 | "user": { 178 | "login": "alexwilson", 179 | "id": 440052, 180 | "node_id": "MDQ6VXNlcjQ0MDA1Mg==", 181 | "avatar_url": "https://avatars.githubusercontent.com/u/440052?v=4", 182 | "gravatar_id": "", 183 | "url": "https://api.github.com/users/alexwilson", 184 | "html_url": "https://github.com/alexwilson", 185 | "followers_url": "https://api.github.com/users/alexwilson/followers", 186 | "following_url": "https://api.github.com/users/alexwilson/following{/other_user}", 187 | "gists_url": "https://api.github.com/users/alexwilson/gists{/gist_id}", 188 | "starred_url": "https://api.github.com/users/alexwilson/starred{/owner}{/repo}", 189 | "subscriptions_url": "https://api.github.com/users/alexwilson/subscriptions", 190 | "organizations_url": "https://api.github.com/users/alexwilson/orgs", 191 | "repos_url": "https://api.github.com/users/alexwilson/repos", 192 | "events_url": "https://api.github.com/users/alexwilson/events{/privacy}", 193 | "received_events_url": "https://api.github.com/users/alexwilson/received_events", 194 | "type": "User", 195 | "site_admin": false 196 | }, 197 | "repo": { 198 | "id": 336912371, 199 | "node_id": "MDEwOlJlcG9zaXRvcnkzMzY5MTIzNzE=", 200 | "name": "enable-github-automerge-action", 201 | "full_name": "alexwilson/enable-github-automerge-action", 202 | "private": false, 203 | "owner": { 204 | "login": "alexwilson", 205 | "id": 440052, 206 | "node_id": "MDQ6VXNlcjQ0MDA1Mg==", 207 | "avatar_url": "https://avatars.githubusercontent.com/u/440052?v=4", 208 | "gravatar_id": "", 209 | "url": "https://api.github.com/users/alexwilson", 210 | "html_url": "https://github.com/alexwilson", 211 | "followers_url": "https://api.github.com/users/alexwilson/followers", 212 | "following_url": "https://api.github.com/users/alexwilson/following{/other_user}", 213 | "gists_url": "https://api.github.com/users/alexwilson/gists{/gist_id}", 214 | "starred_url": "https://api.github.com/users/alexwilson/starred{/owner}{/repo}", 215 | "subscriptions_url": "https://api.github.com/users/alexwilson/subscriptions", 216 | "organizations_url": "https://api.github.com/users/alexwilson/orgs", 217 | "repos_url": "https://api.github.com/users/alexwilson/repos", 218 | "events_url": "https://api.github.com/users/alexwilson/events{/privacy}", 219 | "received_events_url": "https://api.github.com/users/alexwilson/received_events", 220 | "type": "User", 221 | "site_admin": false 222 | }, 223 | "html_url": "https://github.com/alexwilson/enable-github-automerge-action", 224 | "description": "An action for enabling Github Automerge on pull-requests.", 225 | "fork": false, 226 | "url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action", 227 | "forks_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/forks", 228 | "keys_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/keys{/key_id}", 229 | "collaborators_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/collaborators{/collaborator}", 230 | "teams_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/teams", 231 | "hooks_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/hooks", 232 | "issue_events_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/events{/number}", 233 | "events_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/events", 234 | "assignees_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/assignees{/user}", 235 | "branches_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/branches{/branch}", 236 | "tags_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/tags", 237 | "blobs_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/blobs{/sha}", 238 | "git_tags_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/tags{/sha}", 239 | "git_refs_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/refs{/sha}", 240 | "trees_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/trees{/sha}", 241 | "statuses_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/statuses/{sha}", 242 | "languages_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/languages", 243 | "stargazers_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/stargazers", 244 | "contributors_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/contributors", 245 | "subscribers_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/subscribers", 246 | "subscription_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/subscription", 247 | "commits_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/commits{/sha}", 248 | "git_commits_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/commits{/sha}", 249 | "comments_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/comments{/number}", 250 | "issue_comment_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/comments{/number}", 251 | "contents_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/contents/{+path}", 252 | "compare_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/compare/{base}...{head}", 253 | "merges_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/merges", 254 | "archive_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/{archive_format}{/ref}", 255 | "downloads_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/downloads", 256 | "issues_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues{/number}", 257 | "pulls_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls{/number}", 258 | "milestones_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/milestones{/number}", 259 | "notifications_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/notifications{?since,all,participating}", 260 | "labels_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/labels{/name}", 261 | "releases_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/releases{/id}", 262 | "deployments_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/deployments", 263 | "created_at": "2021-02-07T23:25:51Z", 264 | "updated_at": "2021-02-18T23:16:10Z", 265 | "pushed_at": "2021-02-18T23:16:07Z", 266 | "git_url": "git://github.com/alexwilson/enable-github-automerge-action.git", 267 | "ssh_url": "git@github.com:alexwilson/enable-github-automerge-action.git", 268 | "clone_url": "https://github.com/alexwilson/enable-github-automerge-action.git", 269 | "svn_url": "https://github.com/alexwilson/enable-github-automerge-action", 270 | "homepage": null, 271 | "size": 225, 272 | "stargazers_count": 1, 273 | "watchers_count": 1, 274 | "language": "TypeScript", 275 | "has_issues": true, 276 | "has_projects": true, 277 | "has_downloads": true, 278 | "has_wiki": true, 279 | "has_pages": false, 280 | "forks_count": 1, 281 | "mirror_url": null, 282 | "archived": false, 283 | "disabled": false, 284 | "open_issues_count": 1, 285 | "license": null, 286 | "forks": 1, 287 | "open_issues": 1, 288 | "watchers": 1, 289 | "default_branch": "main" 290 | } 291 | }, 292 | "_links": { 293 | "self": { 294 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/1" 295 | }, 296 | "html": { 297 | "href": "https://github.com/alexwilson/enable-github-automerge-action/pull/1" 298 | }, 299 | "issue": { 300 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/1" 301 | }, 302 | "comments": { 303 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/1/comments" 304 | }, 305 | "review_comments": { 306 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/1/comments" 307 | }, 308 | "review_comment": { 309 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/comments{/number}" 310 | }, 311 | "commits": { 312 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls/1/commits" 313 | }, 314 | "statuses": { 315 | "href": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/statuses/b6e6cb9b752a04e870f44df9f493a4b6c2ceefca" 316 | } 317 | }, 318 | "author_association": "CONTRIBUTOR", 319 | "auto_merge": null, 320 | "active_lock_reason": null, 321 | "merged": true, 322 | "mergeable": null, 323 | "rebaseable": null, 324 | "mergeable_state": "unknown", 325 | "merged_by": { 326 | "login": "alexwilson", 327 | "id": 440052, 328 | "node_id": "MDQ6VXNlcjQ0MDA1Mg==", 329 | "avatar_url": "https://avatars.githubusercontent.com/u/440052?v=4", 330 | "gravatar_id": "", 331 | "url": "https://api.github.com/users/alexwilson", 332 | "html_url": "https://github.com/alexwilson", 333 | "followers_url": "https://api.github.com/users/alexwilson/followers", 334 | "following_url": "https://api.github.com/users/alexwilson/following{/other_user}", 335 | "gists_url": "https://api.github.com/users/alexwilson/gists{/gist_id}", 336 | "starred_url": "https://api.github.com/users/alexwilson/starred{/owner}{/repo}", 337 | "subscriptions_url": "https://api.github.com/users/alexwilson/subscriptions", 338 | "organizations_url": "https://api.github.com/users/alexwilson/orgs", 339 | "repos_url": "https://api.github.com/users/alexwilson/repos", 340 | "events_url": "https://api.github.com/users/alexwilson/events{/privacy}", 341 | "received_events_url": "https://api.github.com/users/alexwilson/received_events", 342 | "type": "User", 343 | "site_admin": false 344 | }, 345 | "comments": 0, 346 | "review_comments": 0, 347 | "maintainer_can_modify": false, 348 | "commits": 1, 349 | "additions": 1, 350 | "deletions": 1, 351 | "changed_files": 1 352 | }, 353 | "repository": { 354 | "id": 336912371, 355 | "node_id": "MDEwOlJlcG9zaXRvcnkzMzY5MTIzNzE=", 356 | "name": "enable-github-automerge-action", 357 | "full_name": "alexwilson/enable-github-automerge-action", 358 | "private": false, 359 | "owner": { 360 | "login": "alexwilson", 361 | "id": 440052, 362 | "node_id": "MDQ6VXNlcjQ0MDA1Mg==", 363 | "avatar_url": "https://avatars.githubusercontent.com/u/440052?v=4", 364 | "gravatar_id": "", 365 | "url": "https://api.github.com/users/alexwilson", 366 | "html_url": "https://github.com/alexwilson", 367 | "followers_url": "https://api.github.com/users/alexwilson/followers", 368 | "following_url": "https://api.github.com/users/alexwilson/following{/other_user}", 369 | "gists_url": "https://api.github.com/users/alexwilson/gists{/gist_id}", 370 | "starred_url": "https://api.github.com/users/alexwilson/starred{/owner}{/repo}", 371 | "subscriptions_url": "https://api.github.com/users/alexwilson/subscriptions", 372 | "organizations_url": "https://api.github.com/users/alexwilson/orgs", 373 | "repos_url": "https://api.github.com/users/alexwilson/repos", 374 | "events_url": "https://api.github.com/users/alexwilson/events{/privacy}", 375 | "received_events_url": "https://api.github.com/users/alexwilson/received_events", 376 | "type": "User", 377 | "site_admin": false 378 | }, 379 | "html_url": "https://github.com/alexwilson/enable-github-automerge-action", 380 | "description": "An action for enabling Github Automerge on pull-requests.", 381 | "fork": false, 382 | "url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action", 383 | "forks_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/forks", 384 | "keys_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/keys{/key_id}", 385 | "collaborators_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/collaborators{/collaborator}", 386 | "teams_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/teams", 387 | "hooks_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/hooks", 388 | "issue_events_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/events{/number}", 389 | "events_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/events", 390 | "assignees_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/assignees{/user}", 391 | "branches_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/branches{/branch}", 392 | "tags_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/tags", 393 | "blobs_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/blobs{/sha}", 394 | "git_tags_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/tags{/sha}", 395 | "git_refs_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/refs{/sha}", 396 | "trees_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/trees{/sha}", 397 | "statuses_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/statuses/{sha}", 398 | "languages_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/languages", 399 | "stargazers_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/stargazers", 400 | "contributors_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/contributors", 401 | "subscribers_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/subscribers", 402 | "subscription_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/subscription", 403 | "commits_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/commits{/sha}", 404 | "git_commits_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/git/commits{/sha}", 405 | "comments_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/comments{/number}", 406 | "issue_comment_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues/comments{/number}", 407 | "contents_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/contents/{+path}", 408 | "compare_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/compare/{base}...{head}", 409 | "merges_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/merges", 410 | "archive_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/{archive_format}{/ref}", 411 | "downloads_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/downloads", 412 | "issues_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/issues{/number}", 413 | "pulls_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/pulls{/number}", 414 | "milestones_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/milestones{/number}", 415 | "notifications_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/notifications{?since,all,participating}", 416 | "labels_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/labels{/name}", 417 | "releases_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/releases{/id}", 418 | "deployments_url": "https://api.github.com/repos/alexwilson/enable-github-automerge-action/deployments", 419 | "created_at": "2021-02-07T23:25:51Z", 420 | "updated_at": "2021-02-18T23:16:10Z", 421 | "pushed_at": "2021-02-18T23:16:07Z", 422 | "git_url": "git://github.com/alexwilson/enable-github-automerge-action.git", 423 | "ssh_url": "git@github.com:alexwilson/enable-github-automerge-action.git", 424 | "clone_url": "https://github.com/alexwilson/enable-github-automerge-action.git", 425 | "svn_url": "https://github.com/alexwilson/enable-github-automerge-action", 426 | "homepage": null, 427 | "size": 225, 428 | "stargazers_count": 1, 429 | "watchers_count": 1, 430 | "language": "TypeScript", 431 | "has_issues": true, 432 | "has_projects": true, 433 | "has_downloads": true, 434 | "has_wiki": true, 435 | "has_pages": false, 436 | "forks_count": 1, 437 | "mirror_url": null, 438 | "archived": false, 439 | "disabled": false, 440 | "open_issues_count": 1, 441 | "license": null, 442 | "forks": 1, 443 | "open_issues": 1, 444 | "watchers": 1, 445 | "default_branch": "main", 446 | "temp_clone_token": null, 447 | "network_count": 1, 448 | "subscribers_count": 2 449 | }, 450 | "sender": { 451 | "login": "JakeChampion", 452 | "id": 1569131, 453 | "node_id": "MDQ6VXNlcjE1NjkxMzE=", 454 | "avatar_url": "https://avatars.githubusercontent.com/u/1569131?v=4", 455 | "gravatar_id": "", 456 | "url": "https://api.github.com/users/JakeChampion", 457 | "html_url": "https://github.com/JakeChampion", 458 | "followers_url": "https://api.github.com/users/JakeChampion/followers", 459 | "following_url": "https://api.github.com/users/JakeChampion/following{/other_user}", 460 | "gists_url": "https://api.github.com/users/JakeChampion/gists{/gist_id}", 461 | "starred_url": "https://api.github.com/users/JakeChampion/starred{/owner}{/repo}", 462 | "subscriptions_url": "https://api.github.com/users/JakeChampion/subscriptions", 463 | "organizations_url": "https://api.github.com/users/JakeChampion/orgs", 464 | "repos_url": "https://api.github.com/users/JakeChampion/repos", 465 | "events_url": "https://api.github.com/users/JakeChampion/events{/privacy}", 466 | "received_events_url": "https://api.github.com/users/JakeChampion/received_events", 467 | "type": "User", 468 | "site_admin": false 469 | } 470 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "./lib", 6 | "rootDir": "./src", 7 | "strict": true, 8 | "noImplicitAny": false, 9 | "esModuleInterop": true 10 | }, 11 | "exclude": ["node_modules", "**/*.test.ts"] 12 | } 13 | --------------------------------------------------------------------------------