Skip to content

About

Github Action to cherry-pick commit and create PR on Release Branch

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

50 Commits

Folders and files

Repository files navigation

Cherry-Pick Github Action

Github Action to Cherry Pick commits from a branch (generally, master) and create a PR on another branch (Release branch).

Most of the projects have Release branches and master branch. Master branch is where developers works on but we want to push the changes to the Release branches too.

Action

  • Push to the monitored branch X
  • Get the last commit SHA
  • Checkout the other branch, Y
  • Create a new pr branch Z on the branch Y
  • Cherry Pick the commits from X into Z
  • If the cherry-pick succeeds, publish the branch through the Git Data API and create the PR on base Y
  • If the cherry-pick conflicts, create an issue with conflict-resolution instructions and assign it to Jarvis instead
  • PR title will be prefixed with AUTO

Conditions:

  • If base branch commit contains AUTO, it wont recreate the PR.

Inputs

pr_branch

Required The branch name of on which PR should be created from the cherry-pick commit.

pr_labels

CSV Labels to apply on the PR created. Default: autocreated

commit_sha

The specific commit SHA to cherry-pick. If not provided, it defaults to the triggering commit (GITHUB_SHA).

Tokens

GITHUB_TOKEN is used to create pull requests and issues. Branches are published with the Git Data REST API using GIT_DATA_TOKEN when it is set, or GITHUB_TOKEN as a fallback. The publication token needs contents: write permission. If the cherry-pick changes a workflow file, it also needs permission to create or update workflows.

GITBOT_EMAIL optionally overrides the committer email. When it is unset, the action uses the triggering actor's GitHub noreply address.

Using the Git Data API avoids GitHub's server-side workflow scan on git push while preserving the exact tree produced by the local cherry-pick. The action verifies the remote tree SHA before it creates the branch reference.

Example usage

In this example, all the merges to the branch 0.1.0 will create a PR on 0.1.X branch too.

name: PR for release branch
on:
  push:
    branches:
      - 0.1.0
jobs:
  release_pull_request:
    runs-on: ubuntu-latest
    name: release_pull_request
    steps:
    - name: checkout
      uses: actions/checkout@v1
    - name: Create PR to branch
      uses: gorillio/github-action-cherry-pick@master
      with:
        pr_branch: '0.1.x'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        # Optional: use a separate token for publishing Git objects and the branch.
        GIT_DATA_TOKEN: ${{ github.token }}
        # Optional: override the committer email.
        GITBOT_EMAIL: <BOT_EMAIL>
        DRY_RUN: false

About

Github Action to cherry-pick commit and create PR on Release Branch

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages