Skip to content

Commit a1b609b

Browse files
committed
chore: test workflow on push
1 parent 514dfef commit a1b609b

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

.github/workflows/version_scanner.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ on:
44
push:
55
branches:
66
- main
7+
- feat/add-version-scanner
78
schedule:
89
- cron: '0 7 * * 2' # Run weekly on Tuesdays at 7 AM UTC (mirrors main.yml)
910
workflow_dispatch:
1011

12+
permissions:
13+
contents: read
14+
issues: write
15+
1116
jobs:
1217
scan:
1318
name: Run Version Scanner
@@ -27,4 +32,38 @@ jobs:
2732
2833
- name: Run Version Scanner
2934
run: |
30-
python scripts/version_scanner/version_scanner.py -d python -v 3.7 --stdout
35+
# We pipe the output to a file so we can read it in the next step
36+
python scripts/version_scanner/version_scanner.py -d python -v 3.7 --stdout > scanner_output.csv
37+
38+
- name: Create or update issue on finding
39+
if: failure()
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
TITLE="Version Scanner found deprecated dependencies"
44+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
45+
46+
# Read the first 50 lines to prevent blowing up the issue body if it's massive
47+
CSV_PREVIEW=$(head -n 50 scanner_output.csv)
48+
49+
BODY="The [Version Scanner]($RUN_URL) found deprecated dependencies in the repository.
50+
51+
**Matches Found:**
52+
\`\`\`csv
53+
$CSV_PREVIEW
54+
\`\`\`
55+
*(If there are more than 50 matches, see the workflow logs for the full list)*"
56+
57+
# Mirroring regenerate-all.yml: check if an issue already exists to prevent spam
58+
EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number')
59+
60+
if [ -z "$EXISTING_ISSUE" ]; then
61+
echo "WOULD HAVE CREATED ISSUE:"
62+
echo "gh issue create --title \"$TITLE\" --body \"$BODY\""
63+
# gh issue create --title "$TITLE" --body "$BODY"
64+
else
65+
echo "Issue #$EXISTING_ISSUE already exists."
66+
echo "WOULD HAVE ADDED COMMENT:"
67+
echo "gh issue comment \"$EXISTING_ISSUE\" --body \"Another scanner run found deprecated dependencies: $RUN_URL\""
68+
# gh issue comment "$EXISTING_ISSUE" --body "Another scanner run found deprecated dependencies: $RUN_URL"
69+
fi

0 commit comments

Comments
 (0)