1
0
Fork 0
mirror of https://code.forgejo.org/actions/cascading-pr synced 2025-03-15 06:46:59 +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` | | | 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` | | | 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` | | | 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 | | verbose | if true print verbose information | `false` | false |
| debug | if true print debug information | `false` | false | | debug | if true print debug information | `false` | false |
<!-- action-docs-inputs --> <!-- action-docs-inputs -->

View file

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

View file

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

View file

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

View file

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