diff --git a/deploy.sh b/deploy.sh index 2f3bd16..78e03fe 100644 --- a/deploy.sh +++ b/deploy.sh @@ -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() \ No newline at end of file +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!" \ No newline at end of file