1- name : Monthly check GitHub usernames
1+ name : Monthly check GitHub usernames in CODEOWNERS and MAINTAINERS.md
22
33on :
44 workflow_dispatch :
55 schedule :
6- - cron : " 0 0 1 * *"
6+ - cron : " 0 0 1 * *" # Run on the 1st of every month at midnight UTC
77
88permissions :
99 contents : read
@@ -13,62 +13,63 @@ jobs:
1313 check-usernames :
1414 runs-on : ubuntu-latest
1515 steps :
16- - name : Restore lychee cache
17- id : restore-cache
18- uses : actions/cache/restore@v4
19- with :
20- path : .lycheecache
21- key : cache-lychee-${{ github.sha }}
22- restore-keys : cache-lychee-
2316
24- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+ - name : Checkout repository
18+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2519 with :
2620 fetch-depth : 0
2721
28- - run : |
29- cat .github/CODEOWNERS | grep -o "@[a-zA-Z0-9_-]\+" | sort -u | sed 's/@/https:\/\/api.github.com\/users\//' > usernames.txt
30- cat MAINTAINERS.md | grep -o "\*\*.*@[a-zA-Z0-9_-]\+.*\*\*" | grep -o "@[a-zA-Z0-9_-]\+" | sort -u | sed 's/@/https:\/\/api.github.com\/users\//' >> usernames.txt
31- sort -u usernames.txt -o usernames.txt
22+ # Extract GitHub usernames from the CODEOWNERS and MAINTAINERS.md files
23+ # and convert them to GitHub API URLs for validation
24+ - name : Extract GitHub usernames for validation
25+ run : |
26+ {
27+ # Extract usernames from CODEOWNERS (format: @username)
28+ grep -oP "@[\w-]+" .github/CODEOWNERS
29+
30+ # Extract usernames from MAINTAINERS.md (same format, but wrapped in bold to select only current maintainers)
31+ perl -ne 'm/\*\*.+(@[\w-]+)/ && print "$1\n"' MAINTAINERS.md
32+ } | sort -u | sed 's#@#https://api.github.com/users/#' > username_urls.txt
3233
33- - name : Lychee URL checker
34+ - name : Validate GitHub usernames with the Lychee URL checker
3435 uses : lycheeverse/lychee-action@885c65f3dc543b57c898c8099f4e08c8afd178a2 # v2.6.1
35- id : lychee
36+ id : lychee # Step ID to reference later
3637 continue-on-error : true
3738 with :
3839 args : >-
39- --cache
40- --verbose
41- --no-progress
40+ --verbose
41+ --no-progress
4242 --max-concurrency 25
43- usernames.txt
43+ --output lychee_report.txt
44+ username_urls.txt
4445 env :
45- GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
46+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4647
47- - name : Find the last report issue open
48+ - name : Find an existing username validation issue
4849 uses : micalevisk/last-issue-action@0d40124cc99ac8601c2516007f0c98ef3d27537b # v2.3.0
49- id : last-issue
50+ id : last-issue # Step ID to reference later
5051 with :
51- state : open
52+ state : all
5253 labels : check usernames
5354 env :
5455 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5556
56- - name : Update last report open issue created
57- if : ${{ env.lychee_exit_code != 0 }}
57+ - name : Create or update username validation issue if there are errors
58+ if : steps.lychee.outcome == 'failure'
5859 uses : peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v6.0.0
5960 with :
6061 title : GitHub usernames with errors
61- content-filepath : lychee/out.md
62+ content-filepath : lychee_report.txt
6263 issue-number : ${{ steps.last-issue.outputs.issue-number }}
6364 labels : check usernames
6465
65- - name : Close last report open issue
66- if : ${{ env.lychee_exit_code == 0 && steps.last-issue.outputs.has-found == 'true' }}
67- run : gh issue close ${{ steps.last-issue.outputs.issue-number }}
68-
69- - name : Save lychee cache
70- uses : actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
71- if : always()
72- with :
73- path : .lycheecache
74- key : ${{ steps.restore-cache.outputs.cache-primary-key }}
66+ - name : Close or reopen username validation issue as needed
67+ if : steps.last-issue.outputs.has-found == 'true'
68+ env :
69+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
70+ run : |
71+ if [[ "${{ steps.lychee.outcome }}" == "success" ]]; then
72+ gh issue close ${{ steps.last-issue.outputs.issue-number }} --comment "All usernames are valid again. Closing this issue."
73+ else
74+ gh issue reopen ${{ steps.last-issue.outputs.issue-number }} --comment "Invalid usernames found. Reopening this issue."
75+ fi
0 commit comments