Giter Site home page Giter Site logo

gh-backport-action's Introduction

gh-backport-action: GitHub action to backport a pull request.

Main features:

  • Based on cherry-pick-ing on the branch needing the backport.
  • Supports "Merge Commit", "Rebase and Merge" and "Squash and Merge" options.
  • Opens a new PR if success, opens a new Issue if failure.

โš ๏ธ For this action to work, "Automatically delete head branches" must be disabled.

Usage:

Simple usage:

At each PR merged into master, opens a new Pull Request targeting develop.

name: PR for release branch
on:
  pull_request:
    branches: [ master ]
    types: [ closed ]
jobs:
  release_pull_request:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    name: release_pull_request
    steps:
    - name: checkout
      uses: actions/checkout@v1
    - name: Create PR to branch
      uses: Nathanmalnoury/gh-backport-action@master
      with:
        pr_branch: 'develop'
        github_token: ${{ secrets.GITHUB_TOKEN }}

Using a label to indicate which PR should be backported:

Each Pull Request labeled backport develop, when merged, will be backported on develop.

name: PR for release branch
on:
  pull_request:
    branches: [ master ]
    types: [ closed ]
jobs:
  release_pull_request:
    if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'backport develop')
    runs-on: ubuntu-latest
    name: release_pull_request
    steps:
    - name: checkout
      uses: actions/checkout@v1
    - name: Backport PR by cherry-pick-ing
      uses: Nathanmalnoury/gh-backport-action@master
      with:
        pr_branch: 'develop'
        github_token: ${{ secrets.GITHUB_TOKEN }}

Backport procedure:

When action is triggerred, it first gets the list of commit hashes to backport using GitHub pulls API (#list-commits-on-a-pull-request). This is how all 3 merging options are supported, it also means that even in case of a squash and merge the full list of commits will be cherry-picked.

Using git switch, it then creates a new branch starting on pr_branch and then cherry-pick every commit retrieved.

If the backport procedure was successful, a new PR is open. Otherwise an issue is submitted, with helpful infos (traceback + pr number/target_branch) if github API is reachable.

gh-backport-action's People

Contributors

noozo avatar nathanmalnoury avatar antonioleonardo avatar marcioquental avatar ricardocaronasousa avatar

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.