generated from Templates/Baseline
add upload command (#3)
### 📖 Summary - adds basic upload step ### 📑 Test Plan ✅ CI pipeline tests (Default) ### 💬 Details _No response_ ### 📚 Additional Notes _No response_ Reviewed-on: #3
This commit is contained in:
parent
aec06f2fae
commit
ee1695329e
@ -7,16 +7,18 @@ when:
|
|||||||
variables:
|
variables:
|
||||||
- &build_plugin 'woodpeckerci/plugin-docker-buildx:3.2.1'
|
- &build_plugin 'woodpeckerci/plugin-docker-buildx:3.2.1'
|
||||||
# deployment targets
|
# 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
|
# logins for deployment targets
|
||||||
- publish_logins: &publish_logins
|
- publish_logins: &publish_logins
|
||||||
# Default DockerHub login
|
# Default DockerHub login
|
||||||
- registry: https://index.docker.io/v1/
|
#- registry: https://index.docker.io/v1/
|
||||||
username:
|
# username:
|
||||||
from_secret: docker_user
|
# from_secret: docker_user
|
||||||
password:
|
# password:
|
||||||
from_secret: docker_passwd
|
# from_secret: docker_passwd
|
||||||
# Additional Quay.IO login
|
# Additional Gitea login
|
||||||
- registry: https://gitea.ocram85.com
|
- registry: https://gitea.ocram85.com
|
||||||
username:
|
username:
|
||||||
from_secret: gitea_user
|
from_secret: gitea_user
|
||||||
|
@ -8,15 +8,39 @@ depends_on:
|
|||||||
- "ci"
|
- "ci"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
test-next:
|
next:
|
||||||
image: gitea.ocram85.com/plugins/gitea-package:next
|
image: gitea.ocram85.com/plugins/gitea-package:next
|
||||||
pull: true
|
pull: true
|
||||||
|
secrets: [ gitea_user, gitea_passwd]
|
||||||
settings:
|
settings:
|
||||||
|
user:
|
||||||
|
from_secret: gitea_user
|
||||||
|
password:
|
||||||
|
from_secret: gitea_passwd
|
||||||
debug: "true"
|
debug: "true"
|
||||||
owner: "testuser"
|
owner: "plugins"
|
||||||
package_name: "dummy_package"
|
package_name: "dummy_package"
|
||||||
package_version: "0.1.0"
|
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"
|
update: "true"
|
||||||
when:
|
when:
|
||||||
event: pull_request
|
event: pull_request
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://gitea.ocram85.com/plugins/gitea-package/">
|
<a href="https://gitea.ocram85.com/plugins/gitea-package/">
|
||||||
<img
|
<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"
|
alt="gitea-package"
|
||||||
>
|
>
|
||||||
</a>
|
</a>
|
||||||
@ -21,8 +21,8 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://drone.ocram85.com/plugins/gitea-package">
|
<a href="https://ci.ocram85.com/plugins/gitea-package" target="_blank">
|
||||||
<img src="https://drone.ocram85.com/api/badges/plugins/gitea-package/status.svg" alt="Main Branch Build Status">
|
<img src="https://ci.ocram85.com/api/badges/plugins/gitea-package/status.svg" alt="Main Branch Build Status">
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</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_NAME: $PLUGIN_PACKAGE_NAME" "showSettings"
|
||||||
say "PLUGIN_PACKAGE_VERSION: $PLUGIN_PACKAGE_VERSION" "showSettings"
|
say "PLUGIN_PACKAGE_VERSION: $PLUGIN_PACKAGE_VERSION" "showSettings"
|
||||||
say "PLUGIN_FILE_NAME: $PLUGIN_FILE_NAME" "showSettings"
|
say "PLUGIN_FILE_NAME: $PLUGIN_FILE_NAME" "showSettings"
|
||||||
|
say "PLUGIN_FILE_SOURCE: $PLUGIN_FILE_SOURCE" "showSettings"
|
||||||
say "PLUGIN_UPDATE: $PLUGIN_UPDATE" "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() {
|
uploadArtifact() {
|
||||||
curl --user your_username:your_password_or_token \
|
say "Testing if the artifact already exists in give package version..." "uploadArtifact"
|
||||||
--upload-file path/to/file.bin \
|
fexist=$(testArtifact)
|
||||||
https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin
|
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() {
|
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
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
uploadArtifact
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user