From 1732481b37b04dad2913e0c0bb366dbda664e48f Mon Sep 17 00:00:00 2001 From: Pierre Prinetti Date: Tue, 20 Jun 2023 18:11:33 +0200 Subject: [PATCH] docs: Add pull-request trigger example (#28) Document how to use this action to trigger a backport directly from a pull request, using labels. --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index fa4cd91..1fc2874 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,42 @@ jobs: You can also use this action with other events - you'll just need to specify `target-branch` and `pull-request` params. +For example, this configuration creates a pull request against branch `v1` once the current one is merged, provided that the label `backport-v1` is applied: + +```yaml +name: Pull Request Backporting using BPer + +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backporting: + name: "Backporting" + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + && contains(github.event.pull_request.labels.*.name, 'backport-v1') + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport-v1') + ) + ) + runs-on: ubuntu-latest + steps: + - name: Backporting + uses: lampajr/backporting@main + with: + target-branch: v1 + pull-request: ${{ github.event.pull_request.url }} + auth: ${{ secrets.GITHUB_TOKEN }} +``` + For a complete description of all inputs see [Inputs section](#inputs). ## Limitations