mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-06-28 04:43:44 +00:00
update merge
This commit is contained in:
parent
c87d693481
commit
b89d03dbb7
3 changed files with 43 additions and 9 deletions
|
@ -108,6 +108,10 @@ function pr_head() {
|
|||
pr $1 | jq --raw-output .head.ref
|
||||
}
|
||||
|
||||
function pr_merged() {
|
||||
pr $1 | jq --raw-output .merged
|
||||
}
|
||||
|
||||
function upsert_clone() {
|
||||
local direction=$1 branch=$2 clone=$3
|
||||
|
||||
|
@ -154,7 +158,7 @@ function update() {
|
|||
(
|
||||
cd $TMPDIR/origin
|
||||
ls -l $TMPDIR/destination
|
||||
${options[update]} $TMPDIR/destination
|
||||
${options[update]} $TMPDIR/destination $TMPDIR/destination-pr.json $TMPDIR/origin-pr.json
|
||||
)
|
||||
push destination ${options[destination_head]} ${options[destination_clone]}
|
||||
}
|
||||
|
@ -188,9 +192,17 @@ function run() {
|
|||
wait_destination_ci $(cat $TMPDIR/destination.sha)
|
||||
;;
|
||||
closed)
|
||||
log_info "PR is closed, close the cascade PR and remove the branch"
|
||||
repo_login ${options[destination_repo]}
|
||||
close_pr destination
|
||||
if "$(pr_merged origin)"; then
|
||||
log_info "PR was merged, update the cascade PR"
|
||||
repo_login ${options[destination_repo]}
|
||||
pr origin
|
||||
pr destination
|
||||
update
|
||||
else
|
||||
log_info "PR is closed, close the cascade PR and remove the branch"
|
||||
repo_login ${options[destination_repo]}
|
||||
close_pr destination
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log_info "state '$state', do nothing"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue