Skip to content

Commit

Permalink
Auto CherryPick commits to previous branches
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare authored and JacobCallahan committed Aug 3, 2022
1 parent 0fb6966 commit 965e65b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/auto_cherry_pick.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# CI stages to execute against all branches on PR merge
name: auto_cherry_pick_commits

on:
pull_request_target:
types:
- closed

jobs:
branch-matrix:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick')
name: Generate a branch matrix to apply cherrypicks
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.set-matrix.outputs.branches }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: set-matrix
run: echo "::set-output name=branches::$(git branch -rl --sort=-authordate 'origin/6.*.z' --format='%(refname:lstrip=-1)' | head -n2 | jq -cnR '[inputs | select(length>0)]')"
auto_cherry_picking:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick')
name: Auto Cherry picking
needs: branch-matrix
runs-on: ubuntu-latest
strategy:
matrix:
to_branch: ${{ fromJson(needs.branch-matrix.outputs.branches) }}
steps:
- name: Checkout Nailgun
uses: actions/checkout@v3
with:
fetch-depth: 0
if: matrix.to_branch != github.base_ref
- name: Cherry pick into ${{ matrix.to_branch }}
uses: carloscastrojumo/[email protected]
with:
branch: ${{ matrix.to_branch }}
labels: |
Auto_Cherry_Picked
# skipping PRs remote target_branch from cherrypicking into itself
if: matrix.to_branch != github.base_ref
17 changes: 17 additions & 0 deletions .github/workflows/required_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CI jobs to check specific labels present / absent
name: required_labels

on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]

jobs:
cherrypick_label:
name: Enforcing cherrypick labels
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v2
with:
mode: exactly
count: 1
labels: "CherryPick, No-CherryPick"

0 comments on commit 965e65b

Please sign in to comment.