Skip to content

Commit

Permalink
build: Add auto deploy to GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
akim-13 committed Sep 20, 2024
1 parent 3b41da7 commit 9b597c3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,26 @@ jobs:
PREFIX=ghcr.io/${{ github.repository }}
docker buildx build -t $PREFIX:${{ github.sha }} -t $PREFIX:latest --push .
echo "Image built and pushed with tags: ${{ github.sha }} and latest"
deploy:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Add SSH key for deployment
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Deploy to the server
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
cd /mnt/data/cleaning-website
git checkout production
git pull -X theirs
docker compose -f docker-compose.prod.yml pull django
docker compose -f docker-compose.prod.yml up -d
EOF

0 comments on commit 9b597c3

Please sign in to comment.