mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-04-23 17:20:49 +00:00
85 lines
1.2 KiB
Bash
85 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
# SPDX-License-Identifier: MIT
|
||
|
|
||
|
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||
|
VERBOSE=false
|
||
|
DEBUG=false
|
||
|
: ${EXIT_ON_ERROR:=true}
|
||
|
|
||
|
function debug() {
|
||
|
DEBUG=true
|
||
|
set -x
|
||
|
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
||
|
}
|
||
|
|
||
|
function verbose() {
|
||
|
VERBOSE=true
|
||
|
}
|
||
|
|
||
|
function log() {
|
||
|
echo "$@" >&2
|
||
|
}
|
||
|
|
||
|
function log_error() {
|
||
|
log "$@"
|
||
|
}
|
||
|
|
||
|
function log_verbose() {
|
||
|
if $VERBOSE ; then
|
||
|
log "$@"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
function log_info() {
|
||
|
log "$@"
|
||
|
}
|
||
|
|
||
|
function fatal_error() {
|
||
|
log_error "$@"
|
||
|
if $EXIT_ON_ERROR ; then
|
||
|
exit 1
|
||
|
else
|
||
|
return 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
function push_self() {
|
||
|
local host_port=$1
|
||
|
|
||
|
forgejo-test-helper.sh push_self_action http://root:admin1234@$host_port root cascading-pr vTest
|
||
|
}
|
||
|
|
||
|
function run() {
|
||
|
local host_port=$1 url=$2 token=$3
|
||
|
|
||
|
push_self $host_port
|
||
|
|
||
|
echo do something
|
||
|
}
|
||
|
|
||
|
function main() {
|
||
|
local command=run
|
||
|
local host_port=$(cat forgejo-ip):3000
|
||
|
local url=http://$host_port
|
||
|
local token=$(cat forgejo-token)
|
||
|
|
||
|
while true; do
|
||
|
case "$1" in
|
||
|
--verbose)
|
||
|
shift
|
||
|
verbose
|
||
|
;;
|
||
|
--debug)
|
||
|
shift
|
||
|
debug
|
||
|
;;
|
||
|
*)
|
||
|
"${1:-run}" "$host_port" "$url" "$token"
|
||
|
return 0
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
}
|
||
|
|
||
|
${MAIN:-main} "${@}"
|