Created
May 13, 2021 14:32
-
-
Save dilverdev/b8c59b98b40de4f507f2ceae7112c7ad to your computer and use it in GitHub Desktop.
Deploy bot discord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
. /root/.nvm/nvm.sh | |
export WEBHOOK_URL="" | |
nameBot="Deploy" | |
project=frontend-web | |
curl -H "Content-Type: application/json" -d '{"username": "'"$nameBot"'", "content": "Deployando '"$project"'"}' $WEBHOOK_URL | |
mkdir /var/www/$project/builds/"build-$(date +"%Y%m%d%M%S")" | |
cd /var/www/$project/builds | |
cd "$(ls -dt */ | head -1)" | |
git --work-tree=./ --git-dir=/var/repo/$project/site.git checkout -f | |
cp /var/www/$project/.env ./ | |
ln -sfn $PWD /var/www/$project/link | |
yarn && yarn build | |
pm2 delete $project | |
pm2 start | |
cd .. | |
echo "-------------VESIONS------------" | |
ls -1 | |
echo "-------------VESIONS------------" | |
build="$(ls -dt * | head -1)" | |
cd /var/repo/$project/site.git | |
branch=$(git log -1 --pretty=format:'%d') | |
author=$(git log -1 --pretty=format:'%an') | |
email=$(git log -1 --pretty=format:'%ae') | |
date=$(git log -1 --pretty=format:'%ad') | |
commit=$(git log -1 --pretty=format:'%f') | |
curl \ | |
-H "Content-Type: application/json" \ | |
-d '{"username": "'"$nameBot"'", "content": "Deploy completo '"$project"' => '"$build"'", "embeds":[ | |
{ | |
"fields": [ | |
{"name": "Project", "value": "'"$project"'"}, | |
{"name": "Build", "value": "'"$build"'"}, | |
{"name": "Branch", "value": "'"$branch"'"}, | |
{"name": "Commit", "value": "'"$commit"'"}, | |
{"name": "Author", "value": "'"$author"'", "inline": true}, | |
{"name": "Email", "value": "'"$email"'", "inline": true}, | |
{"name": "Date", "value": "'"$date"'"} | |
], | |
"color": "1011011" | |
} | |
]}' \ | |
$WEBHOOK_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment