generated from Templates/Baseline
extend text output #10
@ -4,44 +4,67 @@ when:
|
|||||||
branch:
|
branch:
|
||||||
- ${CI_REPO_DEFAULT_BRANCH}
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- &build_plugin 'gitea.ocram85.com/plugins/gitea-package:next'
|
||||||
|
- &default_settings
|
||||||
|
user:
|
||||||
|
from_secret: gitea_user
|
||||||
|
password:
|
||||||
|
from_secret: gitea_passwd
|
||||||
|
owner: "plugins"
|
||||||
|
package_name: "dummy_package"
|
||||||
|
package_version: "0.1.0"
|
||||||
|
file_source: "./README.md"
|
||||||
|
file_name: "readme.md"
|
||||||
|
#update: "true"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- "ci"
|
- "ci"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
next:
|
default:
|
||||||
image: gitea.ocram85.com/plugins/gitea-package:next
|
image: *build_plugin
|
||||||
pull: true
|
pull: true
|
||||||
secrets: [ gitea_user, gitea_passwd]
|
secrets: [ gitea_user, gitea_passwd]
|
||||||
settings:
|
settings:
|
||||||
user:
|
<<: *default_settings
|
||||||
from_secret: gitea_user
|
update: "true"
|
||||||
password:
|
when:
|
||||||
from_secret: gitea_passwd
|
event: pull_request
|
||||||
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
debug-out:
|
||||||
|
image: *build_plugin
|
||||||
|
pull: true
|
||||||
|
secrets: [ gitea_user, gitea_passwd]
|
||||||
|
settings:
|
||||||
|
<<: *default_settings
|
||||||
|
update: "true"
|
||||||
debug: "true"
|
debug: "true"
|
||||||
owner: "plugins"
|
|
||||||
package_name: "dummy_package"
|
|
||||||
package_version: "0.1.0"
|
|
||||||
file_source: "./README.md"
|
|
||||||
file_name: "readme.md"
|
|
||||||
update: "true"
|
|
||||||
when:
|
when:
|
||||||
event: pull_request
|
event: pull_request
|
||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
next-nodebug:
|
|
||||||
image: gitea.ocram85.com/plugins/gitea-package:next
|
no-update:
|
||||||
|
image: *build_plugin
|
||||||
pull: true
|
pull: true
|
||||||
|
failure: ignore
|
||||||
secrets: [ gitea_user, gitea_passwd]
|
secrets: [ gitea_user, gitea_passwd]
|
||||||
settings:
|
settings:
|
||||||
user:
|
<<: *default_settings
|
||||||
from_secret: gitea_user
|
debug: "true"
|
||||||
password:
|
when:
|
||||||
from_secret: gitea_passwd
|
event: pull_request
|
||||||
owner: "plugins"
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
package_name: "dummy_package"
|
|
||||||
package_version: "0.1.0"
|
no-update-debug:
|
||||||
file_source: "./README.md"
|
image: *build_plugin
|
||||||
file_name: "readme.md"
|
pull: true
|
||||||
update: "true"
|
failure: ignore
|
||||||
|
secrets: [ gitea_user, gitea_passwd]
|
||||||
|
settings:
|
||||||
|
<<: *default_settings
|
||||||
when:
|
when:
|
||||||
event: pull_request
|
event: pull_request
|
||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
@ -26,13 +26,16 @@ sayW() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
showHelp() {
|
# TODO: Disabled for now. No default help output needed if just running as
|
||||||
cat << HELP
|
# Woodpecker CI plugin.
|
||||||
🤖 gitea-package Woodpecker-CI Plugin
|
#
|
||||||
|
#showHelp() {
|
||||||
Syntax:
|
# cat << HELP
|
||||||
HELP
|
# 🤖 gitea-package Woodpecker-CI Plugin
|
||||||
}
|
#
|
||||||
|
# Syntax:
|
||||||
|
#HELP
|
||||||
|
#}
|
||||||
|
|
||||||
showENV() {
|
showENV() {
|
||||||
env | sort
|
env | sort
|
||||||
@ -75,41 +78,41 @@ deleteArtifact() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadArtifact() {
|
uploadArtifact() {
|
||||||
say "Testing if the artifact already exists in give package version..." "uploadArtifact"
|
say "Testing if the given artifact already exists in the package registry..." "uploadArtifact"
|
||||||
fexist=$(testArtifact)
|
fexist=$(testArtifact)
|
||||||
if [ "$fexist" = "true" ]; then
|
if [ "$fexist" = "true" ]; then
|
||||||
if [ -n "$PLUGIN_UPDATE" ]; then
|
if [ -n "$PLUGIN_UPDATE" ]; then
|
||||||
sayW "Given file already exists. Updating package file..." "uploadArtifact"
|
sayW "🚧 Given file already exists. Removing remote file..." "uploadArtifact"
|
||||||
deleteArtifact
|
deleteArtifact
|
||||||
else
|
else
|
||||||
sayW "A file with the same name exist already in the package." "uploadArtifact"
|
sayW "🛑 File already exists in the package registry." "uploadArtifact"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
say "Starting file upload..." "uploadArtifact"
|
say "Starting file upload... ($PLUGIN_FILE_SOURCE)" "uploadArtifact"
|
||||||
cout=$(curl --silent --output /dev/null --write-out "%{http_code}" \
|
cout=$(curl --silent --output /dev/null --write-out "%{http_code}" \
|
||||||
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" \
|
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" \
|
||||||
--upload-file "$PLUGIN_FILE_SOURCE" \
|
--upload-file "$PLUGIN_FILE_SOURCE" \
|
||||||
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
|
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
|
||||||
say "Curl output is: $cout" "uploadArtifact"
|
say "Curl http response code: $cout" "uploadArtifact"
|
||||||
|
|
||||||
if [ "$cout" = "201" ]; then
|
if [ "$cout" = "201" ]; then
|
||||||
say "Upload sucessfully finished." "uploadArtifact"
|
say "Upload sucessfully finished. ✅" "uploadArtifact"
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$cout" = "400" ]; then
|
elif [ "$cout" = "400" ]; then
|
||||||
sayE "Upload failed! (Bad Request)" "uploadArtifact"
|
sayE "Upload failed! (Bad Request) 💣" "uploadArtifact"
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$cout" = "409" ]; then
|
elif [ "$cout" = "409" ]; then
|
||||||
sayE "File already exists in package version!" "uploadArtifact"
|
sayE "File already exists in package version! 🛑" "uploadArtifact"
|
||||||
else
|
else
|
||||||
sayE "Unknown upload response! ($cout)" "uploadArtifact"
|
sayE "Unknown upload response! ($cout) 💣" "uploadArtifact"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
if [ -n "$PLUGIN_DEBUG" ]; then
|
if [ -n "$PLUGIN_DEBUG" ]; then
|
||||||
sayW "Debug mode enabled."
|
sayW "🐞 Debug mode enabled."
|
||||||
showSettings
|
showSettings
|
||||||
#sayW "Available ENV vars:"
|
#sayW "Available ENV vars:"
|
||||||
#showENV
|
#showENV
|
||||||
|
Loading…
Reference in New Issue
Block a user