Skip to content

fix: deploy

fix: deploy #53

Workflow file for this run

name: Deploy to server
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add server to known_hosts
run: ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- name: Deploy to server
run: |
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} << 'ENDSSH'
cd ${{ secrets.SERVER_DEPLOY_PATH }}
git pull origin main
sudo docker stop ${{ secrets.APP_NAME }} || true
sudo docker rm ${{ secrets.APP_NAME }} || true
sudo docker build -t ${{ secrets.APP_NAME }} .
sudo docker compose up -d
ENDSSH