Giter Club home page Giter Club logo

merge-branch's Introduction

Merge branch action

Runs a git merge in your CI.

Examples:

Sync branches

name: Sync multiple branches
on:
  push:
    branches:
      - '*'
jobs:
  sync-branch:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master

      - name: Merge development -> staging
        uses: devmasx/merge-branch@master
        with:
          type: now
          from_branch: development
          target_branch: staging
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Merge staging -> uat
        uses: devmasx/merge-branch@master
        with:
          type: now
          from_branch: staging
          target_branch: uat
          github_token: ${{ secrets.GITHUB_TOKEN }}

Merge current branch

name: Merge any release branch to uat
on:
  push:
    branches:
      - 'release/*'
jobs:
  merge-branch:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master

      - name: Merge staging -> uat
        uses: devmasx/merge-branch@master
        with:
          type: now
          target_branch: uat
          github_token: ${{ secrets.GITHUB_TOKEN }}

Merge current branch with commit message

name: Merge any release branch to uat
on:
  push:
    branches:
      - 'release/*'
jobs:
  merge-branch:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master

      - name: Merge staging -> uat
        uses: devmasx/merge-branch@master
        with:
          type: now
          target_branch: uat
          message: Merge staging into uat
          github_token: ${{ secrets.GITHUB_TOKEN }}

On labeled

Merge pull request branch using GitHub labels.

When you set a label in a pull request this action can merge the pull request branch to other branch, useful for develop branch or staging environments.

PR Checker

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/merge-branch@master
        with:
          label_name: 'merged in develop'
          target_branch: 'develop'
          github_token: ${{ secrets.GITHUB_TOKEN }}

merge-branch's People

Contributors

andrewfenn avatar cheneyveron avatar dependabot[bot] avatar miguelsavignano avatar misterglass avatar rishabhj1717 avatar spacewaterbear avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

merge-branch's Issues

Workflow doesn't trigger on labeled pull request

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:

  1. documentcloud/underscore-contrib#235 (workflow wasn't on master yet)
  2. documentcloud/underscore-contrib#237 (branch was on my fork)
  3. documentcloud/underscore-contrib#238 (branch on upstream repo, can't explain failure to trigger)

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!

Bypass branch protection rule

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?

Action Config

  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 }}

Error Log

/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>'

Merge commit no longer has a message

I ran into an issue that seems to be a combination of two factors:

  1. In my GitHub Action I have to depend on a master version, because depending on a stable version is not possible (#16)
  2. master branch had a breaking change introduced with this new feature: #18

Step 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:

  1. There is no stable release to depend on (#16)
  2. The newly added optional commit message is not really optional

Frequent false positive merge conflicts

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.

Feature: Ability to replace a branch instead of merge

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?

Auto resolve conflicts

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.

[Question] How do it works the env variable GITHUB_SHA?

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 :)

[Question] Automatic merge from "release/*" to "master"

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}}

Author other than bot

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?

merge silently skiped

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

  • fail if merge is skipped
  • feedback why it is skiped

delete merged branch?

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.

Error while merging

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?

Resource not accessible by integration

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>'

Adding outputs to this action

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?

Getting 404

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?

Does this work with PRs from forks?

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?

500 error

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>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.