chore: another approach

This commit is contained in:
2022-10-29 23:25:48 +02:00
parent 383cdf797f
commit 8d7815b307

View File

@@ -1,26 +1,4 @@
#!/bin/bash
# something went wrong function
something_went_wrong () {
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $COMMITSTATUS" \
https://api.github.com/repos/SrIzan10/vinci/statuses/$(git rev-parse origin/main) \
-d '{"state":"failure","description":"The build errored!","context":"deployment/rpi"}'
}
# send a pending request thing
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $COMMITSTATUS" \
https://api.github.com/repos/SrIzan10/vinci/statuses/$(git rev-parse origin/main) \
-d '{"state":"pending","description":"Building...","context":"deployment/rpi"}'
{
doallstuff () {
git pull
docker build . -t srizan10/vinci
@@ -30,11 +8,8 @@ https://api.github.com/repos/SrIzan10/vinci/statuses/$(git rev-parse origin/main
docker rm vinci
docker run -d -t --name vinci -p 7272:7272 --restart unless-stopped srizan10/vinci
}
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $COMMITSTATUS" \
https://api.github.com/repos/SrIzan10/vinci/statuses/$(git rev-parse origin/main) \
-d '{"state":"success","description":"The build errored!","context":"deployment/rpi"}'
} || something_went_wrong()
if doallstuff()
then env GITHUB_API=$COMMITSTATUS commit-status success deployment/rpi "Deployment succesful!"
else env GITHUB_API=$COMMITSTATUS commit-status failure deployment/rpi "Oops! Something went wrong!"