2023-10-11 15:39:52 +02:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
name: 'Cascading PR'
|
|
|
|
author: 'Forgejo authors'
|
|
|
|
description: |
|
2023-10-13 23:38:57 +02:00
|
|
|
|
|
|
|
When used in a workflow triggered by a PR event, it will create,
|
|
|
|
update and close a matching PR in another repository. Whenever the
|
|
|
|
matching PR is modified by `cascading-pr`, it waits for the CI to
|
|
|
|
pass otherwise it fails.
|
|
|
|
|
|
|
|
As an example, when a PR is created in
|
|
|
|
[`forgejo/runner`](https://code.forgejo.org/forgejo/runner/), a
|
|
|
|
matching PR is created in
|
|
|
|
[`actions/setup-forgejo`](https://code.forgejo.org/actions/setup-forgejo/)
|
|
|
|
with the proposed change. `cascading-pr` will wait until the CI in
|
|
|
|
`actions/setup-forgejo` is successful. When the PR in
|
|
|
|
`forgejo/runner` is merged, the matching PR in
|
|
|
|
`actions/setup-forgejo` is updated to use what was just merged and
|
|
|
|
is ready to be reviewed.
|
|
|
|
|
|
|
|
The `update` script is expected to be found in the checked out repository
|
|
|
|
running the PR. It is given three arguments:
|
|
|
|
|
|
|
|
* A directory in which the destination repository is checked-out
|
|
|
|
* A file with the JSON describing the pull request in the
|
|
|
|
destination repository
|
|
|
|
* A file with the JSON describing the pull request in the
|
|
|
|
origin repository
|
|
|
|
|
|
|
|
If changes are found in the destination repository directory, they will be
|
|
|
|
pushed as a new commit in the PR.
|
2023-10-11 15:39:52 +02:00
|
|
|
|
|
|
|
inputs:
|
2023-10-11 18:05:11 +02:00
|
|
|
origin-url:
|
|
|
|
description: 'URL of the Forgejo instance where the PR that triggers the action is located (e.g. https://code.forgejo.org)'
|
2023-10-11 15:39:52 +02:00
|
|
|
required: true
|
2023-10-11 18:05:11 +02:00
|
|
|
origin-repo:
|
|
|
|
description: 'the repository in which the PR was created'
|
2023-10-11 15:39:52 +02:00
|
|
|
required: true
|
2023-10-11 18:05:11 +02:00
|
|
|
origin-token:
|
|
|
|
description: 'a token with write permission on origin-repo'
|
2023-10-11 15:39:52 +02:00
|
|
|
required: true
|
2023-10-12 19:13:07 +02:00
|
|
|
origin-pr:
|
|
|
|
description: 'number of the PR in {orign-repo}'
|
|
|
|
required: true
|
2023-10-11 18:05:11 +02:00
|
|
|
destination-url:
|
|
|
|
description: 'URL of the Forgejo instance where the cascading PR is created or updated (e.g. https://code.forgejo.org)'
|
|
|
|
required: true
|
|
|
|
destination-repo:
|
|
|
|
description: 'the repository in which the cascading PR is created or updated'
|
|
|
|
required: true
|
|
|
|
destination-branch:
|
|
|
|
description: 'the base branch of the destination repository for the cascading PR'
|
|
|
|
required: true
|
|
|
|
destination-token:
|
|
|
|
description: 'a token with write permission on destination-repo'
|
|
|
|
required: true
|
|
|
|
update:
|
|
|
|
description: 'path to the script to update the content of the cascading PR'
|
|
|
|
required: true
|
2023-10-12 14:57:38 +02:00
|
|
|
prefix:
|
|
|
|
description: 'prefix of the cascading PR created on destination-repo (default to {origin-repo})'
|
2023-10-11 18:05:11 +02:00
|
|
|
verbose:
|
|
|
|
description: 'if true print verbose information'
|
|
|
|
default: false
|
|
|
|
debug:
|
|
|
|
description: 'if true print debug information'
|
|
|
|
default: false
|
2023-10-11 15:39:52 +02:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- run: |
|
2023-10-12 15:00:48 +02:00
|
|
|
export PATH=${{ github.action_path }}:$PATH
|
|
|
|
|
2023-10-11 18:05:11 +02:00
|
|
|
if "${{ inputs.verbose }}"; then
|
|
|
|
verbosity="$verbosity --verbose"
|
|
|
|
fi
|
|
|
|
if "${{ inputs.debug }}"; then
|
|
|
|
verbosity="$verbosity --debug"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cascading-pr.sh $verbosity \
|
|
|
|
--origin-url "${{ inputs.origin-url }}" \
|
|
|
|
--origin-repo "${{ inputs.origin-repo }}" \
|
|
|
|
--origin-token "${{ inputs.origin-token }}" \
|
2023-10-12 19:13:07 +02:00
|
|
|
--origin-pr "${{ inputs.origin-pr }}" \
|
2023-10-11 18:05:11 +02:00
|
|
|
--destination-url "${{ inputs.destination-url }}" \
|
|
|
|
--destination-repo "${{ inputs.destination-repo }}" \
|
|
|
|
--destination-token "${{ inputs.destination-token }}" \
|
|
|
|
--destination-branch "${{ inputs.destination-branch }}" \
|
2023-10-12 15:12:52 +02:00
|
|
|
--update "${{ inputs.update }}" \
|
2023-10-13 14:24:19 +02:00
|
|
|
--prefix "${{ inputs.prefix }}" \
|
|
|
|
run
|