Merge pull request #58 from JahongirHakimjonov/jahongir #25
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 Django Application to Server for Development | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Deploy to Server | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
port: ${{ secrets.SSH_PORT }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
script: | | |
set -e | |
cd ${{ secrets.DEV_DEPLOY_PATH }} | |
echo "Pulling latest changes from dev branch..." | |
git fetch --all | |
git reset --hard origin/dev | |
echo "Building and restarting Docker containers..." | |
docker compose pull | |
docker compose up -d --build | |
echo "Cleaning up unused Docker images..." | |
docker image prune -af | |
echo "Deployment completed successfully!" |