GithubHelp home page GithubHelp logo

jbleyaert / github-cherry-pick-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carloscastrojumo/github-cherry-pick-action

0.0 0.0 0.0 662 KB

GitHub action for cherry pick commits from Pull Requests into Release branchs

License: MIT License

JavaScript 1.63% TypeScript 98.37%

github-cherry-pick-action's Introduction

typescript-action status

Cherry-picking a pull request commit into branchs

This action is designed to be used for cherry-pick commits from pull requests into release branches.

GitHub Cherry Pick Action will:

  • Checkout triggered action.
  • Create new branch name cherry-pick-${GITHUB_SHA} from branch input.
  • Cherry-picking ${GITHUB_SHA} into created branch
  • Push new branch to remote
  • Open pull request to branch

NOTE: The GITHUB_SHA is taken from the GitHub context, specifically from the merge_commit_sha attribute of the pull request object.

Example

Cherry-picking pull requests merged on main to branch release-v1.0 in pull requests labeled with release-v1.0 and to branch release-v2.0 in pull requests labeled with release-v2.0.

on:
  pull_request:
    branches:
      - main
    types: ["closed"]

jobs:
  cherry_pick_release_v1_0:
    runs-on: ubuntu-latest
    name: Cherry pick into release-v1.0
    if: ${{ contains(github.event.pull_request.labels.*.name, 'release-v1.0') && github.event.pull_request.merged == true }}
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Cherry pick into release-v1.0
        uses: carloscastrojumo/[email protected]
        with:
          branch: release-v1.0
          labels: |
            cherry-pick
          reviewers: |
            aReviewerUser
  cherry_pick_release_v2_0:
    runs-on: ubuntu-latest
    name: Cherry pick into release-v2.0
    if: ${{ contains(github.event.pull_request.labels.*.name, 'release-v2.0') && github.event.pull_request.merged == true }}
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Cherry pick into release-v2.0
        uses: carloscastrojumo/[email protected]
        with:
          branch: release-v2.0
          labels: |
            cherry-pick
          reviewers: |
            aReviewerUser
          title: '[cherry-pick] {old_title}'
          body: 'Cherry picking #{old_pull_request_id} onto this branch'
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Using outputs:

steps:
  - uses: actions/checkout@v3
  - uses: carloscastrojumo/[email protected]
    id: new-issue
    with:
      branch: release-v2.0
      labels: cherry-pick
    - run: |
        echo "${{ steps.new-issue.outputs.data }}"
        echo "${{ steps.new-issue.outputs.number }}" 
        echo "${{ steps.new-issue.outputs.html_url }}"

Working with forked repositories

If you are using this action while working with forked repositories (e.g. when you get pull requests from external contributors), you will have to adapt the trigger to avoid permission problems.

In such a case you should use the pull_request_target trigger, which was introduced by github for this usecase.

Example

on:
  pull_request_target:
    branches:
      - main
    types: ["closed"]
 ...

Mor informatoin can be found in the GitHub Blog

Action inputs

Name Description Default
token GITHUB_TOKEN or a repo scoped Personal Access Token (PAT). GITHUB_TOKEN
committer The committer name and email address in the format Display Name <[email protected]>. Defaults to the GitHub Actions bot user. GitHub <[email protected]>
author The author name and email address in the format Display Name <[email protected]>. Defaults to the user who triggered the workflow run. ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch Name of the branch to merge the cherry pick. create-pull-request/patch
labels A comma or newline-separated list of labels.
assignees A comma or newline-separated list of assignees (GitHub usernames).
reviewers A comma or newline-separated list of reviewers (GitHub usernames) to request a review from.
team-reviewers A comma or newline-separated list of GitHub teams to request a review from. Note that a repo scoped PAT may be required.
title Title of the new pull request, the special string {old_title} will be substituted for the title of the pull request which triggered the action [Triggering pull request title]
body Body of the new pull request, the special string {old_pull_request_id} will be substituted for the ID of the pull request which triggered the action [Triggering pull request body]
cherry-pick-branch Name of the new cherry pick branch cherry-pick-${inputs.branch}-${commitSha}
force Set true or false to forcefully push the cherrypicked changes branch to remote branch. false

Action outputs

output value
data See Response
html_url the issue's web url
number the issue's number

License

MIT

github-cherry-pick-action's People

Contributors

carloscastrojumo avatar confectrician avatar dependabot[bot] avatar jyejare avatar lampajr avatar navidshaikh avatar omkarkhatavkar avatar opecheese avatar radtriste avatar samuelcolvin 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.