|
9 | 9 | - main |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - zap: |
13 | | - name: ZAP Scan |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - name: Checkout code |
17 | | - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
18 | | - - name: Set up Docker Buildx |
19 | | - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 |
20 | | - |
21 | | - - name: Build and run Docker Compose |
22 | | - run: | |
23 | | - MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} docker compose -f .github/ci/docker-compose.yml up --build -d |
24 | | - timeout 180 bash -c 'until [ "$(docker compose -f .github/ci/docker-compose.yml ps ceramicraft-user-mservice --format json | jq -r .Health)" = "healthy" ]; do sleep 2; done' |
25 | | - - name: Check Docker Compose Logs |
26 | | - if: failure() |
27 | | - run: | |
28 | | - docker compose -f .github/ci/docker-compose.yml logs |
29 | | - - name: Run ZAP Scan |
30 | | - uses: zaproxy/action-full-scan@75ee1686750ab1511a73b26b77a2aedd295053ed |
31 | | - with: |
32 | | - target: 'http://localhost:8080' # ZAP accesses the host-mapped port |
33 | | - cmd_options: '-s' |
34 | | - fail_action: false # Do not fail CI even if vulnerabilities are found |
35 | | - allow_issue_writing: false # Disable automatic creation of GitHub Issues |
36 | | - issue_title: 'ZAP Security Scan Alert' |
37 | | - artifact_name: 'zap-report' # Attachment report |
38 | | - - name: Tear down |
39 | | - if: always() |
40 | | - run: docker compose -f .github/ci/docker-compose.yml down --volumes --remove-orphans |
| 12 | + generate-env: |
| 13 | + name: Generate .env file |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + env-path: ${{ steps.set-output.outputs.env-path }} |
| 17 | + steps: |
| 18 | + - name: Generate .env file |
| 19 | + run: | |
| 20 | + echo "MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}" >> env-file |
| 21 | + echo "SMTP_PASSWORD=${{ secrets.SMTP_PASSWORD }}" >> env-file |
| 22 | + echo "SMTP_EMAIL_FROM=${{ secrets.SMTP_EMAIL_FROM }}" >> env-file |
| 23 | + echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> env-file |
| 24 | + - name: Upload env-file as artifact |
| 25 | + uses: actions/upload-artifact@v4 |
| 26 | + with: |
| 27 | + name: env-file |
| 28 | + path: env-file |
| 29 | + zap: |
| 30 | + name: ZAP Scan |
| 31 | + runs-on: ubuntu-latest |
| 32 | + needs: |
| 33 | + - generate-env |
| 34 | + steps: |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
| 37 | + - name: Set up Docker Buildx |
| 38 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 |
| 39 | + - name: Download .env file |
| 40 | + uses: actions/download-artifact@v4 |
| 41 | + with: |
| 42 | + name: env-file |
| 43 | + path: . |
| 44 | + - name: Build and run Docker Compose |
| 45 | + run: | |
| 46 | + docker compose -f .github/ci/docker-compose.yml --env-file env-file up --build -d |
| 47 | + timeout 180 bash -c 'until [ "$(docker compose -f .github/ci/docker-compose.yml ps ceramicraft-user-mservice --format json | jq -r .Health)" = "healthy" ]; do sleep 2; done' |
| 48 | + - name: Check Docker Compose Logs |
| 49 | + if: failure() |
| 50 | + run: | |
| 51 | + docker compose -f .github/ci/docker-compose.yml logs |
| 52 | + - name: Run ZAP Scan |
| 53 | + uses: zaproxy/action-full-scan@75ee1686750ab1511a73b26b77a2aedd295053ed |
| 54 | + with: |
| 55 | + target: 'http://localhost:8080' # ZAP accesses the host-mapped port |
| 56 | + cmd_options: '-s' |
| 57 | + fail_action: false # Do not fail CI even if vulnerabilities are found |
| 58 | + allow_issue_writing: false # Disable automatic creation of GitHub Issues |
| 59 | + issue_title: 'ZAP Security Scan Alert' |
| 60 | + artifact_name: 'zap-report' # Attachment report |
| 61 | + - name: Tear down |
| 62 | + if: always() |
| 63 | + run: docker compose -f .github/ci/docker-compose.yml down --volumes --remove-orphans |
0 commit comments