|
| 1 | +name: Dependency Audit |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - '**/requirements.txt' |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - '**/requirements.txt' |
| 10 | + schedule: |
| 11 | + - cron: '0 0 * * *' # Run daily at midnight UTC |
| 12 | + |
| 13 | +jobs: |
| 14 | + audit: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v2 |
| 21 | + with: |
| 22 | + python-version: '3.x' |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip install pip-audit |
| 28 | +
|
| 29 | + - name: Run pip-audit |
| 30 | + run: | |
| 31 | + pip-audit -r requirements.txt > audit_output.txt |
| 32 | + continue-on-error: true |
| 33 | + |
| 34 | + - name: Display audit results |
| 35 | + run: cat audit_output.txt |
| 36 | + |
| 37 | + - name: Create detailed report |
| 38 | + run: | |
| 39 | + echo "Pip Audit Report" > detailed_report.txt |
| 40 | + echo "==================" >> detailed_report.txt |
| 41 | + echo "" >> detailed_report.txt |
| 42 | + echo "Date: $(date)" >> detailed_report.txt |
| 43 | + echo "" >> detailed_report.txt |
| 44 | + echo "Audit Results:" >> detailed_report.txt |
| 45 | + cat audit_output.txt >> detailed_report.txt |
| 46 | + echo "" >> detailed_report.txt |
| 47 | + echo "Environment:" >> detailed_report.txt |
| 48 | + python --version >> detailed_report.txt |
| 49 | + pip --version >> detailed_report.txt |
| 50 | + echo "" >> detailed_report.txt |
| 51 | + echo "Requirements:" >> detailed_report.txt |
| 52 | + cat requirements.txt >> detailed_report.txt |
| 53 | +
|
| 54 | + - name: Upload audit results |
| 55 | + uses: actions/upload-artifact@v2 |
| 56 | + with: |
| 57 | + name: pip-audit-report |
| 58 | + path: detailed_report.txt |
| 59 | + |
0 commit comments