mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-04-21 08:28:44 +00:00
check the status of the cascaded PR
This commit is contained in:
parent
756e6eacb8
commit
b0c8a634f3
2 changed files with 12 additions and 12 deletions
|
@ -93,7 +93,7 @@ function check_status() {
|
||||||
local api="$1"
|
local api="$1"
|
||||||
local sha="$2"
|
local sha="$2"
|
||||||
local expected_status="$3"
|
local expected_status="$3"
|
||||||
local expected_description="$3"
|
local expected_description="$4"
|
||||||
|
|
||||||
get_status $api $sha > $TMPDIR/status.json
|
get_status $api $sha > $TMPDIR/status.json
|
||||||
local status="$(jq --raw-output .state < $TMPDIR/status.json)"
|
local status="$(jq --raw-output .state < $TMPDIR/status.json)"
|
||||||
|
@ -130,9 +130,9 @@ function wait_log() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wait_status() {
|
function wait_status() {
|
||||||
|
local status="$1"
|
||||||
local api="$2"
|
local api="$2"
|
||||||
local sha="$3"
|
local sha="$3"
|
||||||
local status="$1"
|
|
||||||
local description="$4"
|
local description="$4"
|
||||||
|
|
||||||
for i in $(seq $LOOPS); do
|
for i in $(seq $LOOPS); do
|
||||||
|
@ -145,7 +145,7 @@ function wait_status() {
|
||||||
if test $(check_status "$api" "$sha" "$status" "$description") = "OK" ; then
|
if test $(check_status "$api" "$sha" "$status" "$description") = "OK" ; then
|
||||||
log_info "$sha status OK"
|
log_info "$sha status OK"
|
||||||
else
|
else
|
||||||
get_status $url $repo $sha | jq .statuses
|
get_status $api $sha | jq .statuses
|
||||||
log_info "$sha status NOK"
|
log_info "$sha status NOK"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -77,14 +77,13 @@ function push() {
|
||||||
|
|
||||||
(
|
(
|
||||||
cd $TMPDIR/$direction
|
cd $TMPDIR/$direction
|
||||||
if git diff; then
|
git add .
|
||||||
log_info "nothing to push"
|
if git commit -m 'cascading-pr update'; then
|
||||||
else
|
git push --force origin $branch
|
||||||
git add .
|
|
||||||
git commit -m 'cascading-pr update'
|
|
||||||
git push --force-push origin $branch
|
|
||||||
git rev-parse HEAD > ../$direction.sha
|
git rev-parse HEAD > ../$direction.sha
|
||||||
log_info "pushed"
|
log_info "pushed"
|
||||||
|
else
|
||||||
|
log_info "nothing to push"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -100,19 +99,20 @@ function update() {
|
||||||
upsert_clone destination ${options[destination_head]} ${options[destination_clone]}
|
upsert_clone destination ${options[destination_head]} ${options[destination_clone]}
|
||||||
(
|
(
|
||||||
cd $TMPDIR/origin
|
cd $TMPDIR/origin
|
||||||
|
ls -l $TMPDIR/destination
|
||||||
${options[update]} $TMPDIR/destination
|
${options[update]} $TMPDIR/destination
|
||||||
)
|
)
|
||||||
push destination ${options[destination_clone]}
|
push destination ${options[destination_head]} ${options[destination_clone]}
|
||||||
}
|
}
|
||||||
|
|
||||||
function finalize_options() {
|
function finalize_options() {
|
||||||
options[origin_scheme]=$(scheme ${options[origin_url]})
|
options[origin_scheme]=$(scheme ${options[origin_url]})
|
||||||
options[origin_host_port]=$(host_port ${options[origin_url]})
|
options[origin_host_port]=$(host_port ${options[origin_url]})
|
||||||
options[origin_clone]=${options[origin_scheme]}://:${options[origin_token]}@${options[origin_host_port]}/${options[origin_repo]}
|
options[origin_clone]=${options[origin_scheme]}://any:${options[origin_token]}@${options[origin_host_port]}/${options[origin_repo]}
|
||||||
options[origin_head]=$(origin_pr_head)
|
options[origin_head]=$(origin_pr_head)
|
||||||
options[destination_scheme]=$(scheme ${options[destination_url]})
|
options[destination_scheme]=$(scheme ${options[destination_url]})
|
||||||
options[destination_host_port]=$(host_port ${options[destination_url]})
|
options[destination_host_port]=$(host_port ${options[destination_url]})
|
||||||
options[destination_clone]=${options[destination_scheme]}://:${options[destination_token]}@${options[destination_host_port]}/${options[destination_repo]}
|
options[destination_clone]=${options[destination_scheme]}://any:${options[destination_token]}@${options[destination_host_port]}/${options[destination_repo]}
|
||||||
options[destination_base]=${options[destination_branch]}
|
options[destination_base]=${options[destination_branch]}
|
||||||
: ${options[prefix]:=${options[origin_repo]}}
|
: ${options[prefix]:=${options[origin_repo]}}
|
||||||
options[destination_head]=${options[prefix]}-${options[origin_pr]}
|
options[destination_head]=${options[prefix]}-${options[origin_pr]}
|
||||||
|
|
Loading…
Add table
Reference in a new issue