update merge

This commit is contained in:
Earl Warren 2023-10-13 21:08:52 +02:00
parent c87d693481
commit b89d03dbb7
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 43 additions and 9 deletions

View file

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