feat: Allow pushing to different repositories
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
PapaTutuWawa 2024-01-14 19:23:33 +01:00
parent 7abdf4b03c
commit 6fecf6fc11

View File

@ -6,8 +6,20 @@ token_env=${PLUGIN_TOKEN_ENV}
output=${PLUGIN_OUTPUT} output=${PLUGIN_OUTPUT}
name=${PLUGIN_NAME} name=${PLUGIN_NAME}
email=${PLUGIN_EMAIL} email=${PLUGIN_EMAIL}
if [[ -z "$token_env" || -z "$branch" || -z "$name" || -z "$email" ]]; then
echo "Invalid configuration: Token environment variable name, branch name empty, name, or email" # Allow passing a different push SSH URL
clone_url=$CI_REPO_CLONE_SSH_URL
if [[ -n "$PLUGIN_SSH_URL" ]]; then
clone_url=${PLUGIN_SSH_URL}
fi
if [[ -z "$token_env" || -z "$branch" || -z "$name" || -z "$email" || -z "$clone_url" ]]; then
echo "Invalid configuration: Token environment variable name, branch name empty, name, clone URL, or email"
echo "Token env: $token_env"
echo "branch: $branch"
echo "Name: $name"
echo "Email: $email"
echo "Clone URL: $clone_url"
exit 1 exit 1
fi fi
@ -33,4 +45,4 @@ git add --all
git commit -m "Deploy new version $CI_COMMIT_SHA" git commit -m "Deploy new version $CI_COMMIT_SHA"
# Push the repository # Push the repository
git push -u "$CI_REPO_CLONE_SSH_URL" -f "$branch" git push -u "$clone_url" -f "$branch"