Merge pull request #26 from BitwisePushkar/pushkar #28
Workflow file for this run
This file contains hidden or 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: Django CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - development | |
| - authentication | |
| - pushkar | |
| - Arnav | |
| - chat | |
| - feature/* | |
| jobs: | |
| ci-cd: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r auth/requirements.txt | |
| - name: Run tests | |
| run: | | |
| cd auth | |
| python manage.py test | |
| - name: Deploy to EC2 | |
| if: | | |
| github.ref == 'refs/heads/main' || | |
| github.ref == 'refs/heads/development' || | |
| github.ref == 'refs/heads/authentication' || | |
| github.ref == 'refs/heads/pushkar' || | |
| github.ref == 'refs/heads/Arnav' || | |
| github.ref == 'refs/heads/chat' | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| # Navigate to Django project folder | |
| cd /home/ubuntu/tripsync-backend/auth | |
| # Pull latest code | |
| git pull origin $GITHUB_REF_NAME | |
| # Activate virtual environment | |
| source ../env/bin/activate | |
| # Install requirements | |
| pip install -r ../requirements.txt | |
| # Apply migrations and collect static files | |
| python manage.py migrate | |
| python manage.py collectstatic --noinput | |
| # Restart Redis (if managed manually) | |
| sudo systemctl restart redis-server | |
| # Restart Daphne and Nginx | |
| sudo systemctl restart daphne | |
| sudo systemctl restart gunicorn | |
| sudo systemctl restart nginx |