Is it possible to merge pull request automaticaly to master branch on github after success of travis test webhook?
You can most probably add an after_success
action to your .travis.yml
that would merge the PR using GitHub API. I do not know of any ready to use script for this, but there is no reason for it to be hard. Special care needed for authentication ...
You can use Mergify to do this.
It allows to configure rules and define criteria for your pull request to be automatically merged. In your case, setting something like "Travis check is OK and one reviewer approved the PR" would allow the PR to be automatically merged.
(Disclosure: I'm part of the Mergify team.)
You can most probably add an after_success
action to your .travis.yml
that would merge the PR using GitHub API. I do not know of any ready to use script for this, but there is no reason for it to be hard. Special care needed for authentication ...
GitHub recently shipped this auto-merge feature in beta. To use this, you can enable it in the repo settings. Just keep in mind you will need to add branch protection rules as well.
See the documentation for more info.
I recently wrote a blog post describing how to automatically merge trusted pull requests on GitHub.
Essentially, after enabling the required settings on your repository, you can use the following GitHub Actions workflow to tell GitHub to merge the PR automatically after required status checks pass.
name: Auto-merge Dependabot PRs
on: pull_request
permissions:
contents: write
pull-requests: write
jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
If you want to allow auto-merging PRs from users other than dependabot, change the if
condition to use a list of trusted author names:
if: ${{ contains(fromJson('["dependabot[bot]", "octocat"]'), github.actor) }}
P.S. I recognize that the OP asked specifically about Travis CI, but this was the top Google Search result when I started figuring out how to auto merge PRs on GitHub. Hopefully my answer helps others in my same shoes.
I run a bot that does this.
Mergery is:
- Free, including for private repositories.
- Fast. It's event-driven, it doesn't run on a schedule.
- Simple. No configuration required. Just label your PRs with
automerge
.
© 2022 - 2024 — McMap. All rights reserved.