initial import of gogs-notify script and a Docerkfile

This commit is contained in:
Dan Ballard 2018-07-07 13:33:49 -05:00
commit 6b36560b6d
3 changed files with 36 additions and 0 deletions

7
Dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM alpine:3.8
RUN apk add --no-cache ca-certificates curl
COPY gogs-notify /
ENTRY-POINT [/gogs-notify]

14
README.md Normal file
View File

@ -0,0 +1,14 @@
Create a user on Gogs for posting build notifications (like 'buildbot') and generate a token for it. Insert the token as a drone secret.
drone secret add dan/gogs-notify-test --name gogs_account_token --value $VALUE --event pull-request --event push --event tag --event deployment
Use in drone.yml:
notify-gogs:
image: drone-gogs
when:
event: pull_request
secrets: [gogs_account_token]
gogs_url: https://git.openprivacy.ca

15
gogs-notify Normal file
View File

@ -0,0 +1,15 @@
#!/bin/sh
URL="$GOGS_URL/api/v1/repos/${DRONE_REPO}/issues/${DRONE_PULL_REQUEST}/comments"
RESULT=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GOGS_ACCOUNT_TOKEN" -H "Content-Type: application/json" -d "{\"Body\": \"Drone Build Status: ${DRONE_BUILD_STATUS}\n\n${DRONE_BUILD_LINK}\"}" -X POST $URL)
CURL_RESULT=$?
if [ $RESULT -eq 201 ]
then
echo "Success posting to $URL"
else
echo "ERROR posting to $URL"
echo "ERROR http: $RESULT curl: $CURL_RESULT"
exit 1
fi