pip-audit scheduled #12
This file contains hidden or 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: pip-audit scheduled | |
| on: | |
| schedule: | |
| - cron: '0 5 * * 1,4' # Mon & Thu 05:00 UTC | |
| workflow_dispatch: | |
| concurrency: | |
| group: pip-audit-scheduled | |
| cancel-in-progress: true | |
| jobs: | |
| audit: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Cache pip packages | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('.github/workflows/requirements/pip-audit.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install pip-audit | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --require-hashes -r .github/workflows/requirements/pip-audit.txt | |
| - name: Run pip-audit | |
| id: pip_audit | |
| continue-on-error: true | |
| run: | | |
| pip-audit --format json --output audit-results.json | |
| echo "audit_exit_code=$?" >> $GITHUB_OUTPUT | |
| - name: Check audit results file | |
| run: | | |
| if [ ! -f "audit-results.json" ]; then | |
| echo "Error: audit-results.json was not created by pip-audit" | |
| exit 1 | |
| fi | |
| if ! python3 -m json.tool audit-results.json > /dev/null; then | |
| echo "Error: audit-results.json is not valid JSON" | |
| exit 1 | |
| fi | |
| - name: Analyze vulnerabilities | |
| id: analyze_vulnerabilities | |
| run: | | |
| python3 .github/scripts/analyze_vulnerabilities.py | |
| exit_code=$? | |
| echo "vuln_status=$exit_code" >> $GITHUB_OUTPUT | |
| - name: Create security issue | |
| if: steps.analyze_vulnerabilities.outputs.vuln_status == '1' | |
| run: python3 .github/scripts/create_security_issue.py | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload results artifact | |
| if: always() | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.x.x | |
| with: | |
| name: security-audit-results | |
| path: | | |
| audit-results.json | |
| vulnerability_summary.json | |
| - name: Fail job if vulnerabilities found | |
| if: steps.analyze_vulnerabilities.outputs.vuln_status == '1' | |
| run: | | |
| echo "Vulnerabilities found - failing job" | |
| exit 1 |