forked from fastify/github-action-merge-dependabot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69db3d8
Showing
370 changed files
with
88,825 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 @@ | ||
.vscode |
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,31 @@ | ||
# Github Action Merge Dependabot | ||
|
||
This action automatically merges dependabot PRs. | ||
|
||
## Inputs | ||
|
||
### `GITHUB_TOKEN` | ||
|
||
**Required** A github token. | ||
|
||
## Example usage | ||
|
||
```yml | ||
name: CI | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
... | ||
|
||
automerge: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: salmanm/github-action-merge-dependabot@v1 | ||
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }} | ||
with: | ||
github-token: ${{secrets.github_token}} | ||
``` |
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,9 @@ | ||
name: "Github Action Merge Dependabot" | ||
description: "Automatically merge dependabot PRs" | ||
inputs: | ||
GITHUB_TOKEN: | ||
description: "A GitHub token." | ||
required: true | ||
runs: | ||
using: "node12" | ||
main: "index.js" |
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,45 @@ | ||
const core = require('@actions/core') | ||
const github = require('@actions/github') | ||
|
||
const GITHUB_TOKEN = core.getInput('github-token', { required: true }) | ||
|
||
const getMergeMethod = (repo) => { | ||
if (repo.allow_merge_commit) return 'merge' | ||
if (repo.allow_squash_merge) return 'squash' | ||
return 'rebase' | ||
} | ||
|
||
async function run () { | ||
try { | ||
const octokit = github.getOctokit(GITHUB_TOKEN) | ||
|
||
const { repository, pull_request: pr } = github.context.payload | ||
const owner = repository.owner.login | ||
const repo = repository.name | ||
const prNumber = pr.number | ||
|
||
const isDependabotPR = pr.user.login === 'dependabot[bot]' | ||
|
||
if (!isDependabotPR) { | ||
return console.log('Unable to merge') | ||
} | ||
|
||
await octokit.pulls.createReview({ | ||
owner, | ||
repo, | ||
pull_number: prNumber, | ||
event: 'APPROVE' | ||
}) | ||
|
||
await octokit.pulls.merge({ | ||
owner, | ||
repo, | ||
pull_number: prNumber, | ||
merge_method: getMergeMethod(pr.head.repo) | ||
}) | ||
} catch (error) { | ||
core.setFailed(error.message) | ||
} | ||
} | ||
|
||
run() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.