git-backporting/examples/on-pr-merge/automated-workflow.yaml
Andrea Lamparelli 6d6592f958
ci: upgrade github actions (#138)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2024-10-03 20:04:40 +02:00

53 lines
No EOL
1.9 KiB
YAML

name: Automated Backporting on PR merge using Git Backporting
on:
pull_request_target:
types: [closed, labeled]
branches:
- main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
compute-targets:
if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged }}
runs-on: ubuntu-latest
outputs:
target-branches: ${{ steps.set-targets.outputs.targets }}
env:
LABELS: ${{ toJSON(github.event.pull_request.labels) }}
steps:
- name: Set target branches
id: set-targets
uses: kiegroup/kie-ci/.ci/actions/parse-labels@main
with:
labels: ${LABELS}
backporting:
if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged && needs.compute-targets.outputs.target-branches != '[]' }}
name: "[${{ matrix.target-branch }}] - Backporting"
runs-on: ubuntu-latest
needs: compute-targets
strategy:
matrix:
target-branch: ${{ fromJSON(needs.compute-targets.outputs.target-branches) }}
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Backporting
uses: ./
with:
dry-run: true
pull-request: ${{ github.event.pull_request.html_url }}
target-branch: ${{ matrix.target-branch }}
auth: "${{ env.GITHUB_TOKEN }}"
title: "[${{ matrix.target-branch }}] ${{ github.event.pull_request.title }}"
body-prefix: "**Backport:** ${{ github.event.pull_request.html_url }}\r\n\r\n**Note**: comment 'ok to test' to properly launch Jenkins jobs\r\n\r\n"
body: "${{ github.event.pull_request.body }}"
labels: "cherry-pick :cherries:"
inherit-labels: false
bp-branch-name: "${{ matrix.target-branch }}_${{ github.event.pull_request.head.ref }}"