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,60 @@ 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+ grep -oP '@[\w-]+' .github/CODEOWNERS
28+ grep -oP '\*\*.+\K@[\w-]+' MAINTAINERS.md # Only get current maintainers (marked up in **bold**)
29+ } | sort -u | sed 's#@#https://api.github.com/users/#' > username_urls.txt
3230
33- - name : Lychee URL checker
31+ - name : Validate GitHub usernames with the Lychee URL checker
3432 uses : lycheeverse/lychee-action@885c65f3dc543b57c898c8099f4e08c8afd178a2 # v2.6.1
35- id : lychee
33+ id : lychee # Step ID to reference later
3634 continue-on-error : true
3735 with :
3836 args : >-
39- --cache
40- --verbose
41- --no-progress
37+ --verbose
38+ --no-progress
4239 --max-concurrency 25
43- usernames.txt
40+ --output lychee_report.txt
41+ username_urls.txt
4442 env :
45- GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
43+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4644
47- - name : Find the last report issue open
45+ - name : Find an existing username validation issue
4846 uses : micalevisk/last-issue-action@0d40124cc99ac8601c2516007f0c98ef3d27537b # v2.3.0
49- id : last-issue
47+ id : last-issue # Step ID to reference later
5048 with :
51- state : open
49+ state : all
5250 labels : check usernames
5351 env :
5452 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5553
56- - name : Update last report open issue created
57- if : ${{ env.lychee_exit_code != 0 }}
54+ - name : Create or update username validation issue if there are errors
55+ if : steps.lychee.outcome == 'failure'
5856 uses : peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v6.0.0
5957 with :
6058 title : GitHub usernames with errors
61- content-filepath : lychee/out.md
59+ content-filepath : lychee_report.txt
6260 issue-number : ${{ steps.last-issue.outputs.issue-number }}
6361 labels : check usernames
6462
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 }}
63+ - name : Close or reopen username validation issue as needed
64+ if : steps.last-issue.outputs.has-found == 'true'
65+ env :
66+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67+ run : |
68+ if [[ "${{ steps.lychee.outcome }}" == "success" ]]; then
69+ gh issue close ${{ steps.last-issue.outputs.issue-number }} --comment "All usernames are valid again. Closing this issue."
70+ else
71+ gh issue reopen ${{ steps.last-issue.outputs.issue-number }} --comment "Invalid usernames found. Reopening this issue."
72+ fi
0 commit comments