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

use repo_login direction token instead of only the destination token

This commit is contained in:
Earl Warren 2023-10-27 13:50:52 +02:00
parent 5caaedbc52
commit 5a9a13f9e7
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -11,11 +11,12 @@ source $SELF_DIR/cascading-pr-lib.sh
trap "rm -fr $TMPDIR" EXIT
function repo_login() {
local repo="$1"
local direction="$1"
local repo=${options[${direction}_repo]}
(
export DOT=$TMPDIR/$repo
forgejo-curl.sh logout
forgejo-curl.sh --token "${options[destination_token]}" login "${options[destination_url]}"
forgejo-curl.sh --token "${options[${direction}_token]}" login "${options[${direction}_url]}"
)
}
@ -250,13 +251,13 @@ function run() {
case "$state" in
open)
log_info "PR is open, update or create the cascade branch and PR"
repo_login ${options[destination_repo]}
repo_login destination
upsert_destination_branch
update
local sha=$(sha_pushed destination)
if test "$sha" ; then
upsert_destination_pr
repo_login ${options[origin_repo]}
repo_login origin
comment_origin_pr
wait_destination_ci "$sha"
fi
@ -265,18 +266,18 @@ function run() {
if "$(pr_merged origin)"; then
if "${options[close_merge]}" ; then
log_info "PR is merged, close the cascade PR and remove the branch"
repo_login ${options[destination_repo]}
repo_login destination
close_pr
else
log_info "PR was merged, update the cascade PR"
repo_login ${options[destination_repo]}
repo_login destination
pr_get origin
pr_get destination
update
fi
else
log_info "PR is closed, close the cascade PR and remove the branch"
repo_login ${options[destination_repo]}
repo_login destination
close_pr
fi
;;