generated from Templates/Baseline
extend text output (#10)
### 📖 Summary - add tests ### 📑 Test Plan ✅ CI pipeline tests (Default) ### 💬 Details _No response_ ### 📚 Additional Notes _No response_ Reviewed-on: #10
This commit is contained in:
parent
0426f300c6
commit
8ce38ad8d7
@ -4,44 +4,67 @@ when:
|
||||
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:
|
||||
- "ci"
|
||||
|
||||
steps:
|
||||
next:
|
||||
image: gitea.ocram85.com/plugins/gitea-package:next
|
||||
default:
|
||||
image: *build_plugin
|
||||
pull: true
|
||||
secrets: [ gitea_user, gitea_passwd]
|
||||
settings:
|
||||
user:
|
||||
from_secret: gitea_user
|
||||
password:
|
||||
from_secret: gitea_passwd
|
||||
<<: *default_settings
|
||||
update: "true"
|
||||
when:
|
||||
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"
|
||||
owner: "plugins"
|
||||
package_name: "dummy_package"
|
||||
package_version: "0.1.0"
|
||||
file_source: "./README.md"
|
||||
file_name: "readme.md"
|
||||
update: "true"
|
||||
when:
|
||||
event: pull_request
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
next-nodebug:
|
||||
image: gitea.ocram85.com/plugins/gitea-package:next
|
||||
|
||||
no-update:
|
||||
image: *build_plugin
|
||||
pull: true
|
||||
failure: ignore
|
||||
secrets: [ gitea_user, gitea_passwd]
|
||||
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"
|
||||
<<: *default_settings
|
||||
debug: "true"
|
||||
when:
|
||||
event: pull_request
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
||||
no-update-debug:
|
||||
image: *build_plugin
|
||||
pull: true
|
||||
failure: ignore
|
||||
secrets: [ gitea_user, gitea_passwd]
|
||||
settings:
|
||||
<<: *default_settings
|
||||
when:
|
||||
event: pull_request
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
@ -26,13 +26,16 @@ sayW() {
|
||||
fi
|
||||
}
|
||||
|
||||
showHelp() {
|
||||
cat << HELP
|
||||
🤖 gitea-package Woodpecker-CI Plugin
|
||||
|
||||
Syntax:
|
||||
HELP
|
||||
}
|
||||
# TODO: Disabled for now. No default help output needed if just running as
|
||||
# Woodpecker CI plugin.
|
||||
#
|
||||
#showHelp() {
|
||||
# cat << HELP
|
||||
# 🤖 gitea-package Woodpecker-CI Plugin
|
||||
#
|
||||
# Syntax:
|
||||
#HELP
|
||||
#}
|
||||
|
||||
showENV() {
|
||||
env | sort
|
||||
@ -75,41 +78,41 @@ deleteArtifact() {
|
||||
}
|
||||
|
||||
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)
|
||||
if [ "$fexist" = "true" ]; 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
|
||||
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
|
||||
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}" \
|
||||
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" \
|
||||
--upload-file "$PLUGIN_FILE_SOURCE" \
|
||||
"$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
|
||||
say "Upload sucessfully finished." "uploadArtifact"
|
||||
say "Upload sucessfully finished. ✅" "uploadArtifact"
|
||||
exit 0
|
||||
elif [ "$cout" = "400" ]; then
|
||||
sayE "Upload failed! (Bad Request)" "uploadArtifact"
|
||||
sayE "Upload failed! (Bad Request) 💣" "uploadArtifact"
|
||||
exit 1
|
||||
elif [ "$cout" = "409" ]; then
|
||||
sayE "File already exists in package version!" "uploadArtifact"
|
||||
sayE "File already exists in package version! 🛑" "uploadArtifact"
|
||||
else
|
||||
sayE "Unknown upload response! ($cout)" "uploadArtifact"
|
||||
sayE "Unknown upload response! ($cout) 💣" "uploadArtifact"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ -n "$PLUGIN_DEBUG" ]; then
|
||||
sayW "Debug mode enabled."
|
||||
sayW "🐞 Debug mode enabled."
|
||||
showSettings
|
||||
#sayW "Available ENV vars:"
|
||||
#showENV
|
||||
|
Loading…
Reference in New Issue
Block a user