generated from Templates/Baseline
add upload command #3
@ -7,16 +7,18 @@ when:
|
||||
variables:
|
||||
- &build_plugin 'woodpeckerci/plugin-docker-buildx:3.2.1'
|
||||
# deployment targets
|
||||
- &publish_repos 'ocram85/plugin-gitea-package,gitea.ocram85.com/plugins/gitea-package'
|
||||
# TODO: Disabled docker hub target until first release is ready / Rate Limits
|
||||
#- &publish_repos 'ocram85/plugin-gitea-package,gitea.ocram85.com/plugins/gitea-package'
|
||||
- &publish_repos 'gitea.ocram85.com/plugins/gitea-package'
|
||||
# logins for deployment targets
|
||||
- publish_logins: &publish_logins
|
||||
# Default DockerHub login
|
||||
- registry: https://index.docker.io/v1/
|
||||
username:
|
||||
from_secret: docker_user
|
||||
password:
|
||||
from_secret: docker_passwd
|
||||
# Additional Quay.IO login
|
||||
#- registry: https://index.docker.io/v1/
|
||||
# username:
|
||||
# from_secret: docker_user
|
||||
# password:
|
||||
# from_secret: docker_passwd
|
||||
# Additional Gitea login
|
||||
- registry: https://gitea.ocram85.com
|
||||
username:
|
||||
from_secret: gitea_user
|
||||
|
@ -8,15 +8,39 @@ depends_on:
|
||||
- "ci"
|
||||
|
||||
steps:
|
||||
test-next:
|
||||
next:
|
||||
image: gitea.ocram85.com/plugins/gitea-package:next
|
||||
pull: true
|
||||
secrets: [ gitea_user, gitea_passwd]
|
||||
settings:
|
||||
user:
|
||||
from_secret: gitea_user
|
||||
password:
|
||||
from_secret: gitea_passwd
|
||||
debug: "true"
|
||||
owner: "testuser"
|
||||
owner: "plugins"
|
||||
package_name: "dummy_package"
|
||||
package_version: "0.1.0"
|
||||
file_name: "./README.md"
|
||||
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
|
||||
pull: true
|
||||
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"
|
||||
when:
|
||||
event: pull_request
|
||||
|
@ -6,7 +6,7 @@
|
||||
<p align="center">
|
||||
<a href="https://gitea.ocram85.com/plugins/gitea-package/">
|
||||
<img
|
||||
src="/plugins/gitea-package/raw/branch/master/assets/social-logo.png"
|
||||
src="/plugins/gitea-package/raw/branch/main/assets/social-logo.png"
|
||||
alt="gitea-package"
|
||||
>
|
||||
</a>
|
||||
@ -21,8 +21,8 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://drone.ocram85.com/plugins/gitea-package">
|
||||
<img src="https://drone.ocram85.com/api/badges/plugins/gitea-package/status.svg" alt="Main Branch Build Status">
|
||||
<a href="https://ci.ocram85.com/plugins/gitea-package" target="_blank">
|
||||
<img src="https://ci.ocram85.com/api/badges/plugins/gitea-package/status.svg" alt="Main Branch Build Status">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 151 KiB |
@ -43,23 +43,78 @@ 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_FILE_SOURCE: $PLUGIN_FILE_SOURCE" "showSettings"
|
||||
say "PLUGIN_UPDATE: $PLUGIN_UPDATE" "showSettings"
|
||||
}
|
||||
|
||||
testArtifact() {
|
||||
tout=$(curl --silent --output /dev/null --write-out "%{http_code}" \
|
||||
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
|
||||
|
||||
if [ "$tout" = "200" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
deleteArtifact() {
|
||||
dout=$(curl --silent --output /dev/null --write-out "%{http_code}" \
|
||||
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" -X DELETE \
|
||||
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
|
||||
|
||||
if [ "$dout" = "204" ]; then
|
||||
say "Old package file deleted" "deleteArtifact"
|
||||
elif [ "$dout" = "404" ]; then
|
||||
sayE "The package or file was not found." "deleteArtifact"
|
||||
exit 1
|
||||
else
|
||||
sayE "Unknown curl response! ($dout)" "deleteArtifact"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
say "Testing if the artifact already exists in give package version..." "uploadArtifact"
|
||||
fexist=$(testArtifact)
|
||||
if [ "$fexist" = "true" ]; then
|
||||
if [ -n "$PLUGIN_UPDATE" ]; then
|
||||
sayW "Given file already exists. Updating package file..." "uploadArtifact"
|
||||
deleteArtifact
|
||||
else
|
||||
sayW "A file with the same name exist already in the package." "uploadArtifact"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
say "Starting file upload..." "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"
|
||||
|
||||
if [ "$cout" = "201" ]; then
|
||||
say "Upload sucessfully finished." "uploadArtifact"
|
||||
exit 0
|
||||
elif [ "$cout" = "400" ]; then
|
||||
sayE "Upload failed! (Bad Request)" "uploadArtifact"
|
||||
exit 1
|
||||
elif [ "$cout" = "409" ]; then
|
||||
sayE "File already exists in package version!" "uploadArtifact"
|
||||
else
|
||||
sayE "Unknown upload response! ($cout)" "uploadArtifact"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ -n "$PLUGIN_DEBUG" ]; then
|
||||
sayW "Debug mode enabled."
|
||||
showSettings
|
||||
sayW "Available ENV vars:"
|
||||
showENV
|
||||
exit 0
|
||||
#sayW "Available ENV vars:"
|
||||
#showENV
|
||||
fi
|
||||
uploadArtifact
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user