-
Notifications
You must be signed in to change notification settings - Fork 1.7k
78 lines (65 loc) · 2.79 KB
/
Copy pathversion_scanner.yml
File metadata and controls
78 lines (65 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Version Scan
on:
push:
branches:
- main
- '**version-scanner**'
schedule:
- cron: '0 * * * *' # Run hourly at the top of the hour
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
scan:
name: Version Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml
- name: Run Version Scanner
run: |
# Uses -o to output a detailed, raw CSV to a file
# Uses --stdout to print a slim, easier to parse summary to the GitHub Actions UI
# Uses --soft-fail to temporarily limit causing CI/CD failures during the migration to full operation.
python scripts/version_scanner/version_scanner.py -d python -v 3.7 --stdout -o version_scanner_output.csv --soft-fail
- name: Upload CSV Results
if: always()
uses: actions/upload-artifact@v7
with:
name: version-scanner-results
path: version_scanner_output.csv
- name: Create or update issue on finding
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TITLE="Version Scanner found deprecated dependencies"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Read the first 50 lines to prevent blowing up the issue body if it's massive
CSV_PREVIEW=$(head -n 50 version_scanner_output.csv)
BODY="The [Version Scanner]($RUN_URL) found deprecated dependencies in the repository.
**Matches Found:**
\`\`\`csv
$CSV_PREVIEW
\`\`\`
*(If there are more than 50 matches, see the workflow logs for the full list)*"
# Mirroring regenerate-all.yml: check if an issue already exists to prevent spam
EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number')
if [ -z "$EXISTING_ISSUE" ]; then
echo "WOULD HAVE CREATED ISSUE:"
echo "gh issue create --title \"$TITLE\" --body \"$BODY\""
# gh issue create --title "$TITLE" --body "$BODY"
else
echo "Issue #$EXISTING_ISSUE already exists."
echo "WOULD HAVE ADDED COMMENT:"
echo "gh issue comment \"$EXISTING_ISSUE\" --body \"Another scanner run found deprecated dependencies: $RUN_URL\""
# gh issue comment "$EXISTING_ISSUE" --body "Another scanner run found deprecated dependencies: $RUN_URL"
fi