Skip to content

Commit

Permalink
Update coverage-workflow.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Garima Ketan Chauhan authored and GitHub Enterprise committed Apr 2, 2025
1 parent 21cdf32 commit dd1a427
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions .github/workflows/coverage-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,74 @@
name: Test Coverage
name: Production Deployment Workflow

on:
push:
branches:
- main
pull_request:
- gargi-production # Trigger only for production branch

jobs:
test:
deploy:
runs-on: self-hosted
env:
REPO_NAME: ${{ github.event.repository.name }}
COMPOSE_FILE: docker-compose.yml

steps:
- name: Check out code
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Dotenv Action
- name: Dotenv Action
uses: falti/dotenv-action@v1.1.4
with:
export-variables: true
keys-case: bypass

# Step 3: Build Docker image for tests
- name: Build Docker image for tests
working-directory: backend
run: |
docker build -t coverage-test -f tests/Dockerfile.test .
- name: Run tests in Docker container
# Step 4: Run tests in Docker container
- name: Run tests with coverage
run: |
docker run coverage-test
# Step 5: Upload coverage results
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: backend/tests/coverage.xml

# Step 6: Set up test containers for staging
- name: Set up test containers
run: docker compose -f docker-compose.stag.yml up --build -d

# Step 7: Run backend unit tests in staging
- name: Run backend unit tests
run: docker exec secfit_stag_backend python manage.py test tests

# Step 8: Tear down test containers
- name: Tear down test containers
run: docker compose -f docker-compose.stag.yml down

# Step 9: Tear down previous production containers
- name: Tear down previous production containers (if any)
run: docker compose -f $COMPOSE_FILE down || true

# Step 10: Build and run production containers
- name: Build and run docker image
run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d

# Step 11: Print deployment message
- name: Print deployment message
run: |
echo "Code has been updated and deployed to the server!"
echo "Commit hash: ${{ github.sha }}"
echo "Branch: ${{ github.ref }}"
# Step 12: Verify gateway availability
- name: Verify that gateway is available
run: docker ps

0 comments on commit dd1a427

Please sign in to comment.