46 lines
1.2 KiB
Shell
Executable file
46 lines
1.2 KiB
Shell
Executable file
#!/bin/bash
|
|
|
|
# inputs are just envvars starting with INPUT_, spaces replaced with _, and
|
|
# converted to uppercase
|
|
REPOSITORY=$INPUT_REPOSITORY
|
|
REF=$INPUT_REF
|
|
TOKEN=$INPUT_TOKEN
|
|
TGT_PATH=$INPUT_PATH
|
|
FETCH_DEPTH=$(printenv INPUT_FETCH-DEPTH)
|
|
SHOW_PROGRESS=$(printenv INPUT_SHOW-PROGRESS)
|
|
RECURSE_SUBMODULES=$(printenv INPUT_RECURSE-SUBMODULES)
|
|
SERVER_URL=$(printenv INPUT_SERVER-URL)
|
|
USER=$FORGEJO_ACTOR
|
|
|
|
# outputs are... not supported, I don't care
|
|
|
|
ARGS=''
|
|
|
|
if [[ -n "$REF" ]]; then
|
|
ARGS="$ARGS -b $REF"
|
|
fi
|
|
|
|
if [[ -n "$FETCH_DEPTH" ]]; then
|
|
ARGS="$ARGS --depth $FETCH_DEPTH"
|
|
fi
|
|
|
|
if [[ "$SHOW_PROGRESS" == "true" ]] || [[ "$SHOW_PROGRESS" == "True" ]]; then
|
|
ARGS="$ARGS --progress"
|
|
fi
|
|
|
|
if [[ "$RECURSE_SUBMODULES" == "true" ]] || [[ "$RECURSE_SUBMODULES" == "True" ]]; then
|
|
ARGS="$ARGS --recurse-submodules"
|
|
fi
|
|
|
|
|
|
# strip https:// from the url
|
|
if ! [[ "$SERVER_URL" =~ ^https:// ]]; then
|
|
echo "Only https server urls are supported now. Provided server url: $SERVER_URL"
|
|
exit 1
|
|
fi
|
|
SERVER_URL=$(echo $SERVER_URL | sed -e 's/^https:\/\///g')
|
|
|
|
# construct the entire url with user and token included
|
|
URL=https://$USER\:$TOKEN\@$SERVER_URL/$REPOSITORY
|
|
|
|
git clone $ARGS $URL $GITHUB_WORKSPACE/$TGT_PATH
|