Automatically Upload Nightly Artifacts if a Release is Cut
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2024-02-23 13:06:26 -08:00
parent eaae82ef55
commit caf85f337b
Signed by: sarah
GPG Key ID: F27FD21A270837EF
2 changed files with 21 additions and 0 deletions

View File

@ -139,6 +139,8 @@ steps:
- scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/
- ./gen-nightly-index.sh $DIR
- scp -r -o StrictHostKeyChecking=no -i ~/id_rsa cwtch-nightly.html buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/
# Upload Files to releases...if a release has been cut...
- ./uploaded-releases.sh deploy/cwtch-`cat VERSION`.apk application/vnd.android.package-archive
- name: notify-gogs
image: openpriv/drone-gogs

19
upload-releases.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
VERSION=$(cat VERSION)
echo "Grabbing Release Data From:" "https://git.openprivacy.ca/api/v1/repos/$DRONE_REPO/releases/tags/$VERSION"
RELEASEID=$(curl -s -X 'GET' "https://git.openprivacy.ca/api/v1/repos/$DRONE_REPO/releases/tags/$VERSION" -H 'accept: application/json' | jq '.id')
echo $RELEASEID
URL="$PLUGIN_GOGS_URL/api/v1/repos/$DRONE_REPO/releases/$RELEASEID/assets?name=$1"
FILE="@$1"
RESULT=$(curl -o /dev/null -w "%{http_code}" -X POST -H "Authorization: token $GOGS_ACCOUNT_TOKEN" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "attachment=$FILE;type=$2" $URL)
if [ $RESULT -eq 201 ]
then
echo "Success posting to $URL"
else
echo "ERROR HTTP $RESULT posting to $URL"
exit 1
fi