Skip to content

Instantly share code, notes, and snippets.

@lzy3me
Created February 27, 2024 13:06
Show Gist options
  • Save lzy3me/ca85e7214bdc45bcf150bc6f569fb382 to your computer and use it in GitHub Desktop.
Save lzy3me/ca85e7214bdc45bcf150bc6f569fb382 to your computer and use it in GitHub Desktop.
Manual Deployment Script w/ Error track and call out via LINE Notify
#!/bin/sh
# manual deployment script
if [ $# -ne 1 ]; then
echo "Usage: $0 <service_name>"
exit 1
fi
service=$1
# if you have prefix name in your docker compose services just add it to val down below
prefix=
notify_auth=LINE_NOTIFY_TOKEN_HERE
curl --location 'https://notify-api.line.me/api/notify' \
--header 'Authorization: Bearer '$notify_auth \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'message="'$service': deploying 🔴"'
cd ./$service && git fetch && git pull && cd ..
docker compose down --rmi all $prefix$service
err=$(docker compose up -d $prefix$service 2>&1 1>/dev/null)
echo $?
if [ $? -ne 0 ]; then
curl --location 'https://notify-api.line.me/api/notify' \
--header 'Authorization: Bearer '$notify_auth \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'message='"$service"': '"$err"' ❌'
echo $err
exit 1
fi
curl --location 'https://notify-api.line.me/api/notify' \
--header 'Authorization: Bearer '$notify_auth \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'message="'$service': completed 🟢"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment