Skip to content

chore: add label build-image-on-pr to trigger a build #7717

chore: add label build-image-on-pr to trigger a build

chore: add label build-image-on-pr to trigger a build #7717

name: PR for release branch
on:
pull_request:
branches:
- main
types: ["closed", "labeled"]
jobs:
get-release-branches:
if: |
github.event.pull_request.merged &&
((github.event.action == 'labeled' && startsWith(github.event.label.name, 'need-cherry-pick')) ||
(github.event.action == 'closed' && contains(toJson(github.event.pull_request.labels), 'need-cherry-pick')))
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.get-release-branches.outputs.branches }}
steps:
- name: Get release branches
id: get-release-branches
run: |
if [[ ${{ github.event.action }} == 'labeled' ]]; then
echo "branches=[\"$(echo ${{ github.event.label.name }} | cut -d '-' -f 4-)\"]" >> "$GITHUB_OUTPUT"
else
labels='${{ toJson(github.event.pull_request.labels) }}'
echo branches=$(echo "$labels" | jq -r '.[] | select(.name | contains("need-cherry-pick")).name' | cut -d '-' -f 4- | jq --raw-input . | jq --slurp . -c) >> "$GITHUB_OUTPUT"
fi
release_pull_request:
needs:
- get-release-branches
runs-on: ubuntu-latest
strategy:
matrix:
branch: ${{ fromJson(needs.get-release-branches.outputs.branches) }}
steps:
- name: checkout
uses: actions/checkout@v1
- name: Create PR to branch
uses: risingwavelabs/github-action-cherry-pick@master
with:
pr_branch: ${{ matrix.branch }}
pr_labels: 'cherry-pick'
pr_body: ${{ format('Cherry picking \#{0} onto branch {1}', github.event.number, matrix.branch) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
issues: write
pull-requests: write
contents: write