This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
fix actions #85
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: Docker Compose Test Workflow | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
compose-build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker Compose services | |
working-directory: ./Docker | |
run: docker-compose -f docker-compose.yml build | |
env: | |
POSTGRES_DB: app | |
POSTGRES_USER: app | |
POSTGRES_PASSWORD: app | |
DJANGO_ENVIRONMENT: test | |
DJANGO_SUPERUSER_USERNAME: admin | |
DJANGO_SUPERUSER_EMAIL: [email protected] | |
DJANGO_SUPERUSER_PASSWORD: admin | |
NATS_USER: user | |
NATS_PASSWORD: password | |
DOMAIN: sae.local | |
- name: Start Docker Compose services | |
run: docker-compose -f Docker/docker-compose.yml up -d | |
- name: Run Trivy vulnerability scanner on all images | |
run: | | |
docker-compose -f Docker/docker-compose.yml config | grep 'image:' | awk '{print $2}' | xargs -I {} sh -c 'trivy image --exit-code 1 --ignore-unfixed {} || exit 1' | |
- name: Check website connection | |
run: | | |
curl -k --retry 5 --retry-delay 5 --retry-connrefused https://${{ env.DOMAIN }} && \ | |
curl -k --retry 5 --retry-delay 5 --retry-connrefused https://api.${{ env.DOMAIN }} | |
env: | |
DOMAIN: sae.local | |
- name: Scan requirements for CVEs in Django API container | |
run: | | |
docker-compose -f Docker/docker-compose.yml exec -T django_api /bin/bash -c "pip install safety && safety check -r /app/requirements.txt --full-report" | |
- name: Scan requirements for CVEs in Django API container | |
run: | | |
docker-compose -f Docker/docker-compose.yml exec -T django_frontend /bin/bash -c "pip install safety && safety check -r /app/requirements.txt --full-report" | |
- name: Cleanup | |
run: docker-compose -f Docker/docker-compose.yml down |