gitea-package/gitea-package.sh

66 lines
1.4 KiB
Bash
Raw Normal View History

2024-05-13 11:00:14 +02:00
#!/usr/bin/env sh
2024-05-13 15:19:22 +02:00
set -e
2024-05-13 11:00:14 +02:00
say() {
if [ -n "$2" ]; then
printf "🤖 \e[32mgitea-package\e[0m \e[36m[⚒️ %s]\e[0m: %s \n" "$2" "$1"
else
printf "🤖 \e[32mgitea-package\e[0m: %s \n" "$1"
fi
}
sayE() {
if [ -n "$2" ]; then
printf "🤖 \e[31mgitea-package\e[0m \e[36m[⚒️ %s]\e[0m: %s \n" "$2" "$1" 1>&2
else
printf "🤖 \e[31mgitea-package\e[0m: %s \n" "$1" 1>&2
fi
}
sayW() {
if [ -n "$2" ]; then
printf "🤖 \e[33mgitea-package\e[0m \e[36m[⚒️ %s]\e[0m: %s \n" "$2" "$1" 1>&2
else
printf "🤖 \e[33mgitea-package\e[0m: %s \n" "$1" 1>&2
fi
}
showHelp() {
cat << HELP
🤖 gitea-package Woodpecker-CI Plugin
Syntax:
HELP
}
2024-05-14 07:31:31 +02:00
showENV() {
env | sort
}
showSettings() {
say "PLUGIN_OWNER: $PLUGIN_OWNER" "showSettings"
say "PLUGIN_PACKAGE_NAME: $PLUGIN_PACKAGE_NAME" "showSettings"
say "PLUGIN_PACKAGE_VERSION: $PLUGIN_PACKAGE_VERSION" "showSettings"
say "PLUGIN_FILE_NAME: $PLUGIN_FILE_NAME" "showSettings"
say "PLUGIN_UPDATE: $PLUGIN_UPDATE" "showSettings"
}
uploadArtifact() {
curl --user your_username:your_password_or_token \
--upload-file path/to/file.bin \
https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin
2024-05-13 11:00:14 +02:00
}
main() {
2024-05-13 14:47:32 +02:00
if [ -n "$PLUGIN_DEBUG" ]; then
2024-05-14 07:31:31 +02:00
sayW "Debug mode enabled."
showSettings
2024-05-14 07:38:26 +02:00
sayW "Available ENV vars:"
2024-05-13 15:03:24 +02:00
showENV
2024-05-14 07:21:00 +02:00
exit 0
2024-05-13 14:47:32 +02:00
fi
2024-05-13 11:00:14 +02:00
}
main "$@"