Merge pull request #31 from skullzarmy/snyk-fix-798e5d39a5d452a9839de… #35
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
name: Deploy to DigitalOcean | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Deploy to DigitalOcean | |
env: | |
PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }} | |
HOST: ${{ secrets.DROPLET_IP }} | |
USERNAME: skullzarmy | |
run: | | |
echo "$PRIVATE_KEY" > deploy_key | |
chmod 600 deploy_key | |
# Git Pull | |
ssh -o StrictHostKeyChecking=no -i deploy_key $USERNAME@$HOST "cd /home/skullzarmy/chatGPToot && git pull origin master" && echo "Git pull successful" | |
# NPM Install | |
ssh -o StrictHostKeyChecking=no -i deploy_key $USERNAME@$HOST "cd /home/skullzarmy/chatGPToot && npm install" && echo "NPM install successful" | |
# Kill Existing Bot Process | |
ssh -o StrictHostKeyChecking=no -i deploy_key $USERNAME@$HOST "pkill -f 'screen -S chatgptoot_bot_session -X quit || true" && echo "Attempted to kill existing bot processes" | |
# Start Bot | |
ssh -o StrictHostKeyChecking=no -i deploy_key $USERNAME@$HOST "cd /home/skullzarmy/chatGPToot && screen -dmS chatgptoot_bot_session node app/chatgptoot.js > logs/bot-log.log 2>&1" && echo "Bot started" | |
# Remove Deploy Key | |
echo "Removing deploy key" | |
rm -f deploy_key |