Update deploy_test.yml #99
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: Production Deployment Workflow | |
| on: | |
| push: | |
| branches: | |
| - gargi-production # Trigger only for production branch | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| env: | |
| REPO_NAME: ${{ github.event.repository.name }} | |
| COMPOSE_FILE: docker-compose.yml | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Dotenv Action | |
| uses: falti/dotenv-action@v1.1.4 | |
| with: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Remove all previous containers (staging & production) | |
| run: | | |
| echo "Removing all previous containers (staging & production)" | |
| docker compose -f docker-compose.stag.yml down || true | |
| docker compose -f $COMPOSE_FILE down || true | |
| docker system prune -af || true | |
| - name: Set up test containers | |
| run: docker compose -f docker-compose.stag.yml up --build -d | |
| - name: Run backend unit tests with coverage | |
| run: | | |
| docker exec secfit_stag_backend coverage run --source='.' manage.py test | |
| docker exec secfit_stag_backend coverage report | |
| - name: Tear down test containers | |
| run: docker compose -f docker-compose.stag.yml down | |
| - name: Build and run docker image | |
| run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d | |
| - name: Print deployment message | |
| run: | | |
| echo "Code has been updated and deployed to the server!" | |
| echo "Commit hash: ${{ github.sha }}" | |
| echo "Branch: ${{ github.ref }}" | |
| - name: Verify that gateway is available | |
| run: docker ps |