1
0
Fork 0
mirror of https://code.forgejo.org/actions/cascading-pr synced 2025-03-14 22:36:58 +01:00

close-merge is close and applies to destination-ref as well

* workflows that have close-merge need to change to close
* the behavior for when origin-pr is set does not change
* the behavior for when origin-ref is set is to honor close
  instead of always closing the PR
This commit is contained in:
Earl Warren 2024-01-09 19:47:48 +01:00
parent 5007c13756
commit 09dc15f425
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
5 changed files with 14 additions and 10 deletions

View file

@ -88,7 +88,7 @@ not exist, it is created.
| destination-token | a token with write permission on destination-repo | `true` | |
| update | path to the script to update the content of the cascading PR | `true` | |
| prefix | prefix of the branch from which the cascading PR is created on {destination-repo} or {destination-fork-repo} (default to {origin-repo}) | `false` | |
| close-merge | if true the cascading PR will be closed and the branch deleted when the PR is merged | `false` | false |
| close | if true the cascading PR will be closed and the branch deleted when the PR is merged | `false` | false |
| verbose | if true print verbose information | `false` | false |
| debug | if true print debug information | `false` | false |
<!-- action-docs-inputs -->

View file

@ -103,8 +103,8 @@ inputs:
required: true
prefix:
description: 'prefix of the branch from which the cascading PR is created on {destination-repo} or {destination-fork-repo} (default to {origin-repo})'
close-merge:
description: 'if true the cascading PR will be closed and the branch deleted when the PR is merged'
close:
description: 'if true the cascading PR will be closed and the branch deleted when (i) the {origin-pr} is merged or (ii) when the cascading PR status is success if {origin-ref} is set'
default: false
verbose:
description: 'if true print verbose information'
@ -145,5 +145,5 @@ runs:
--destination-branch "${{ inputs.destination-branch }}" \
--update "${{ inputs.update }}" \
--prefix "${{ inputs.prefix }}" \
--close-merge "${{ inputs.close-merge }}" \
--close "${{ inputs.close }}" \
run

View file

@ -385,7 +385,7 @@ function finalize_options() {
options[destination_is_fork]=false
fi
: ${options[close_merge]:=false}
: ${options[close]:=false}
}
function run() {
@ -414,7 +414,10 @@ function run_origin_ref() {
log_info "cascade PR status failed"
status=1
fi
close_pr
if "${options[close]}" ; then
log_info "close the cascade PR and remove the branch"
close_pr
fi
return $status
fi
}
@ -436,7 +439,7 @@ function run_origin_pr() {
;;
closed)
if "$(pr_merged origin)"; then
if "${options[close_merge]}" ; then
if "${options[close]}" ; then
log_info "PR is merged, close the cascade PR and remove the branch"
close_pr
else
@ -528,9 +531,9 @@ function main() {
options[prefix]=$1
shift
;;
--close-merge)
--close)
shift
options[close_merge]=$1
options[close]=$1
shift
;;
*)

View file

@ -16,5 +16,6 @@ jobs:
destination-repo: user2/destinationrepo
destination-branch: main
destination-token: ${{ secrets.DESTINATION_TOKEN }}
close: true
update: ./upgraded
debug: true

View file

@ -21,5 +21,5 @@ jobs:
destination-branch: main
destination-token: ${{ secrets.DESTINATION_TOKEN }}
update: ./upgraded
close-merge: true
close: true
debug: true