add private ssh, droplet ip secrets #4
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: CI/CD Workflow | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths: | ||
- 'backend/**' | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup SSH | ||
run: | | ||
mkdir -p ~/.ssh/ | ||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
ssh-keyscan -H ${{ secrets.DROPLET_IP }} >> ~/.ssh/known_hosts | ||
- name: Install doctl | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
- name: Deploy to DigitalOcean | ||
run: | | ||
# Use doctl to interact with your DigitalOcean droplet | ||
# You'll want to replace `<droplet-ID>` and `<path-to-your-app>` | ||
doctl compute ssh 357096535 -- 'cd /home/vimracing && git pull && cd backend && yarn run build && pm2 delete vimracing >2 /dev/null && pm2 start dist/index.js --name vimracing' |