docs: Add pull-request trigger example (#28)

Document how to use this action to trigger a backport directly from a
pull request, using labels.
This commit is contained in:
Pierre Prinetti 2023-06-20 18:11:33 +02:00 committed by GitHub
parent ee94ec83f6
commit 1732481b37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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