Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yaronkaikov committed Feb 7, 2024
1 parent 5d7f443 commit 6c3c5db
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/backport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dynamic Backport PR

on:
pull_request:
types: [closed]
branch: [master]

jobs:
backport:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Extract Target Branch from Label
id: extract_branch
uses: actions/github-script@v5
with:
script: |
const labels = context.payload.pull_request.labels;
const backportLabel = labels.find(label => label.name.startsWith('backport/'));
if (!backportLabel) throw new Error('No backport label found');
const targetBranch = backportLabel.name.replace('backport/', 'next-');
return targetBranch;
result-encoding: 'string'

- name: Log Target Branch
run: echo "The target branch is ${{ steps.extract_branch.outputs.result }}"

- name: Backport to Target Branch
if: steps.extract_branch.outputs.result
uses: tibdex/backport@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
backport_to: ${{ steps.extract_branch.outputs.result }}

0 comments on commit 6c3c5db

Please sign in to comment.