Skip to content

Deploy

Deploy #11

Workflow file for this run

name: Deploy
on:
workflow_run:
workflows: ["Run Tests"]
branches: [main]
types:
- completed
workflow_dispatch:
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: "Deploy to VPS"
runs-on: ubuntu-latest
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy-key.pem
chmod 600 ~/.ssh/deploy-key.pem
cat >> ~/.ssh/config <<END
Host my-vps
HostName $SSH_IP
User $SSH_USER
IdentityFile ~/.ssh/deploy-key.pem
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_IP: ${{ secrets.SSH_IP }}
- name: Deploy Site
run: ssh my-vps 'cd ${{ secrets.PROJECT_ROOT }} && chmod +x redeploy-site.sh && ./redeploy-site.sh && sudo docker compose ps'
- name: Notify Discord
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚀 Deployment Successful"