devmasx / merge-branch Goto Github PK
View Code? Open in Web Editor NEWA GitHub Action that merge PR branch to other branchs
A GitHub Action that merge PR branch to other branchs
I'd like to implement this in our "read the docs" repository where contributors contribute PRs from their personal (public) forks. My goal is to auto merge labeled PRs into a development branch so that Read the Docs will auto-build the latest developer docs to make it easy to view content/changes introduced by PRs.
But I keep getting this error:
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/mautic/developer-documentation-new/merges: 403 - Resource not accessible by integration
I'm using the following for the action
name: Merge branch with labeled
on:
pull_request:
types: [labeled]
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge by labeled
uses: devmasx/[email protected]
with:
label_name: 'review'
target_branch: 'development'
github_token: ${{ secrets.GITHUB_TOKEN }}
Any thoughts?
Hi! I'm trying to use this and I'm getting the following error. Any ideas?
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/MY_ORG/MY_REPO/merges: 500 - (Octokit::InternalServerError)
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in `block in call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in `on_complete'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:130:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:143:in `build_response'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in `run_request'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in `post'
from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:156:in `request'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in `post'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:214:in `merge'
from /action/lib/index.rb:21:in `<main>'
Hi there, I'm trying to merge master
back into develop
automatically. I've got the configuration setup however my develop
branch is protected and requires at least one reviewer and a PR to be submitted. Is there a way to bypass these protection rules when using this action?
merge-branch:
name: Merge `master` back into `develop`
runs-on: ubuntu-latest
needs: [create-release]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: merge `master` to `develop`
uses: devmasx/merge-branch@master
with:
type: now
target_branch: develop
github_token: ${{ secrets.REPO_ACCESS_TOKEN }}
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/digital-ai/dot-components/merges: 409 - protected branch 'develop' check failed: (Octokit::Conflict)
3 of 3 required status checks are expected. At least 1 approving review is required by reviewers with write access. // See: https://docs.github.com/rest/reference/repos#merge-a-branch
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in `block in call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in `on_complete'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:130:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:143:in `build_response'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in `run_request'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in `post'
from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:156:in `request'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in `post'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:214:in `merge'
from /action/lib/index.rb:31:in `<main>'
Is there a way to also delete the merged branch?
I've tried looking at the API, but can't seem to find a way to do it. [might also be simply in-experienced]
This will allow total automation of some tasks instead of having to delete merged branches later.
Hello there!
A few days ago, i started a personal project with github actions (because it's cool). After that, i wanted create a little post deploy routine (staging->master, master->develop, develop->staging), and i found this cool repo to do the job. But, i dont know if i use it correctly, because the env variable GITHUB_SHA dont be overwrited inside the container. I triying this snipet:
---
jobs:
sync:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
ref: master
- name: Sync
uses: devmasx/[email protected]
with:
type: now
target_branch: 'my_target_branch'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_SHA: 'my_head_branch'
I've tried with other custom env variables. and they are overwrited. Is it possible to create an optional new input heads_branch
?
If you wish, i can help you :)
Hello, thank you for this handy action.
I think it would be a good idea to add outputs to this action. (Merge successful, merge conflicts, merge skipped...)
I could maybe work on it if you want?
Hi,
I see that you use Octokit to merge a branch. It seems possible to add a commit message :
https://www.rubydoc.info/github/pengwynn/octokit/Octokit/Client/Commits#merge-instance_method
My goal is to use your Github Actions in order to merge a branch when a milestone is closed. I want to add the milestone title to the merge message.
Hi,
i'm looking for a way to mirror the same author and commit message onto the target branch? is such a thing feasible and is that in your release pipeline?
Thanks for this awesome gh action. Been using it for years now
I have a new workflow idea and I want to force push / replace another branch with the current branch. (rather than merge into)
It seems pretty close to the current API so I thought maybe it could just be another option, e.g.
- name: deploy/stage-a
uses: devmasx/[email protected]
with:
label_name: 'deploy stage-a'
from_branch: ${{ env.GITHUB_HEAD_REF_SLUG }}
target_branch: 'deploy/stage-a'
github_token: ${{ github.token }}
replace: true
Thoughts on what it would take to implement this? Could it be accepted?
I want to know if it's possible if we can avoid creating merge commit and do a fast forward with some option. Right now it creates two commits
e.g. https://github.com/piyushchauhan2011/bug-free-palm-tree/commits/staging
hey, sometimes I'm getting this error during the merge phase:
Run devmasx/merge-branch@master with: type: now from_branch: release target_branch: metadata github_token: ***
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in "on_complete": POST https://api.github.com/repos/ORG/REPO/merges: 409 - Merge conflict // See: https://docs.github.com/rest/reference/repos#merge-a-branch (Octokit::Conflict) from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in "block in call" from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in "on_complete" from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in "call" from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in "perform_with_redirection" from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in "call" from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:130:in "call" from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:143:in "build_response" from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in "run_request" from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in "post" from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in "call" from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:156:in "request" from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in "post" from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:214:in "merge" from /action/lib/index.rb:31:in "<main>"
Any ideas why is it failing?
Hi, thanks for your action!
I'm trying to use it to create an integration branch -- every time we get a PR or a push to master, we merge them into a "preview" branch. Sometimes it works as it should, but frequently, it fails, supposedly due to merge conflicts. But in nearly all of these cases, we're quite confident there's no merge conflict -- we're adding a brand new file or changing something that no other PR touches. And if we manually rebuilt the preview branch, it would be fine.
I'm wondering if you've seen this kind of behavior in other settings with this action?
Looking at the code, it is hard to see how it could go wrong here, but my colleagues and I are at a loss to understand what's happening. Thanks for any help.
Found out that workflows by GitHub actions using a GitHub token don't trigger other workflows (due to concern of infinite loop).
Is it as simple as swapping to my PAT to avoid this issue?
Can't use latest version 1.4.0 in my gh action. Throws error.
Using
name: Merge branch
uses: devmasx/[email protected]
I ran into an issue that seems to be a combination of two factors:
master
version, because depending on a stable version is not possible (#16)master
branch had a breaking change introduced with this new feature: #18Step config in my case:
- name: Merge develop -> staging
uses: devmasx/merge-branch@master
with:
type: now
from_branch: develop
target_branch: staging
github_token: ${{ secrets.LYRA_REPO_ACCESS_TOKEN }}
Previously (e.g. on 2021-10-27) this resulted in a commit with a message Merge develop into staging
.
Today (2021-11-02) this resulted in an empty commit message.
There was no change in configuration.
So I think these are really two issues:
Received Resource not accessible by integration
error when running in workflow.
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/i3drobotics/phase-dev/merges: 403 - Resource not accessible by integration // See: https://docs.github.com/rest/reference/repos#merge-a-branch (Octokit::Forbidden)
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in `block in call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in `on_complete'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:[13](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:14)0:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:[14](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:15)3:in `build_response'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in `run_request'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in `post'
from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:[15](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:16)6:in `request'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in `post'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:[21](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:22)4:in `merge'
from /action/lib/index.rb:31:in `<main>'
Hey there!
Any chance to add a flag to decide what branch to take when conflicts are happening.
We want to have different versions for different branches, but we cant resolve the conflicts for now.
Trying github actions for the 1st time here.
My plans are to update any new pull request with last master changes:
on:
pull_request:
branches:
- "release/**"
jobs:
sync-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge master -> release
uses: devmasx/[email protected]
with:
type: now
head_to_merge: master
target_branch: ${{ github.ref }}
github_token: ${{ github.token }}
but this it's throwing me:
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/visfleet/test-merge-action/merges: 404 - Base does not exist // See: https://docs.github.com/rest/reference/repos#merge-a-branch (Octokit::NotFound)
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in `block in call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in `on_complete'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:130:in `call'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:143:in `build_response'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in `run_request'
from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in `post'
from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:156:in `request'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in `post'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:214:in `merge'
from /action/lib/index.rb:21:in `<main>'
My guessing is the problem comes from the access token, so I've tried using github_token: ${{ secrets.GITHUB_TOKEN }}
, also adding:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
but nothing seems to work. Any idea?
This may or may not be an issue with the merge-branch action; I thought I'd try here before contacting GitHub.
I'm trying to set up a workflow where, when the "ready to launch" label is set on a pull request for a release/*
branch, the branch in question is merged into another branch called prepublish
. This workflow is defined here. It was inspired on the documentation.
I have made three failed attempts at triggering this workflow:
master
yet)Either I'm misunderstanding how to do this, or something doesn't work as advertised in merge-branch or in the GH Actions API. Can you help me? Thanks in advance!
I'm interested in setting up a flow where any changes (pushes or merged pull requests) to a release branch (release/*
) gets automatically merged down to master
, and looks like your action might be able to help with that. Would a configuration like this work?
name: Merge release branch to master
on:
push:
branches:
- 'release/*'
jobs:
automerge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge to master
uses: devmasx/[email protected]
with:
type: now
target_branch: 'master'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
I have included this step into my job
steps:
- uses: actions/checkout@v3
- name: Merge ${{ env.SOURCE_BRANCH }} -> ${{ env.TARGET_BRANCH }}
uses: devmasx/merge-branch@master
with:
target_branch: ${{ env.TARGET_BRANCH }}
github_token: ${{ secrets.GIT_PRIVATE_TOKEN }}
The message is Neutral: skip merge target_branch: staging @head_to_merge: 64cea87bb4409975f4759c985f0ff59ec22bc1f3
.
I would expect
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.