woodpecker-ssg-deploy/entrypoint.sh
Alexander "PapaTutuWawa 510e60a42e
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
Initial commit
2024-01-05 22:21:16 +01:00

27 lines
910 B
Bash

#!/bin/ash
branch=${PLUGIN_BRANCH:-"pages"}
token_env=${PLUGIN_TOKEN_ENV}
output=${PLUGIN_OUTPUT}
if [[ -z "$token_env" ]] || [[ -z "$branch" ]]; then
echo "Invalid configuration: Token environment variable name or branch name empty"
exit 1
fi
tokenified_url=$(/bin/ci-wrapper --clone-url "$CI_REPO_CLONE_URL" --token-env "$token_env")
if [[ "$?" -ne "0" ]]; then
echo "Failed to tokenify clone URL"
exit 1
fi
[[ -n "$PLUGIN_EMAIL" ]] && git config --config user.email "$PLUGIN_EMAIL"
[[ -n "$PLUGIN_NAME" ]] && git config --config user.name "$PLUGIN_NAME"
git config --global --add safe.directory "$CI_WORKSPACE/$CI_REPO_OWNER/$CI_REPO_NAME/$output"
# Init a new repository in the output directory and add all files
git init -b "$branch" "$output"
cd "$output"
git add --all
git commit -m "Deploy new version $CI_COMMIT_SHA"
# Push the repository
git push -u "$tokenified_url" -f "$branch"