-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Glenn Jocher <[email protected]>
- Loading branch information
1 parent
e7cb915
commit b5c016b
Showing
1 changed file
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ name: Check Website links | |
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
schedule: | ||
- cron: "0 0 * * *" # runs at 00:00 UTC every day | ||
|
||
|
@@ -86,6 +87,39 @@ jobs: | |
--no-verbose \ | ||
--force-directories | ||
- name: Run codespell on downloaded pages | ||
id: codespell | ||
continue-on-error: true # Ensure the workflow continues even if spelling errors are found | ||
run: | | ||
pip install codespell | ||
CODESPELL_OUTPUT=$(find ${{ matrix.website }} -type f -name "*.html" -print0 | xargs -0 codespell \ | ||
--ignore-words-list "crate,nd,ned,strack,dota,ane,segway,fo,gool,winn,commend,bloc,nam,afterall,skelton,goin,referer,pre,uint,dto,linkedin,webp,webgl,href,onclick,github,api,http,png,svg,gif,jpg,jpeg,href,js" \ | ||
--skip "*.pt,*.pth,*.torchscript,*.onnx,*.tflite,*.pb,*.bin,*.param,*.mlmodel,*.engine,*.npy,*.data*,*.csv,*pnnx*,*venv*,*translat*,*lock*,__pycache__*,*.ico,*.jpg,*.png,*.mp4,*.mov,/runs,/.git,./docs/??/*.md,./docs/mkdocs_??.yml" \ | ||
2>&1 || true) | ||
echo "$CODESPELL_OUTPUT" | ||
# Process CODESPELL_OUTPUT | ||
MODIFIED_OUTPUT=$(echo "$CODESPELL_OUTPUT" | sed 's#\(.*/\)[^/]*:[0-9]*: \(.*\)#\1 \2#') | ||
echo "$MODIFIED_OUTPUT" | ||
# Check for spelling errors | ||
if [[ "$CODESPELL_OUTPUT" == *"==>"* ]]; then | ||
echo "Spelling errors found ⚠️" | ||
echo "CODESPELL_SUMMARY<<EOF" >> $GITHUB_ENV | ||
echo "## 📝 Spelling Errors" >> $GITHUB_ENV | ||
# Use MODIFIED_OUTPUT here instead of CODESPELL_OUTPUT | ||
echo "$MODIFIED_OUTPUT" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
# Set output for Slack notification | ||
echo "CODESPELL_ERRORS=$CODESPELL_SUMMARY" >> $GITHUB_OUTPUT | ||
echo "CODESPELL_FAILED=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "No spelling errors found ✅" | ||
echo "CODESPELL_FAILED=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Run Broken Link Checks on Website | ||
id: lychee | ||
uses: ultralytics/actions/retry@main | ||
|
@@ -139,11 +173,27 @@ jobs: | |
exit 1 | ||
fi | ||
- name: Check for failure and notify | ||
- name: Add spelling errors to GitHub Summary | ||
if: always() && steps.codespell.outputs.CODESPELL_FAILED == 'true' | ||
run: | | ||
echo "${{ env.CODESPELL_SUMMARY }}" >> $GITHUB_STEP_SUMMARY | ||
- name: Notify Slack for broken links | ||
if: always() && steps.lychee.outcome == 'failure' && github.event_name == 'schedule' && github.run_attempt == '1' | ||
uses: slackapi/[email protected] | ||
with: | ||
webhook-type: incoming-webhook | ||
webhook: ${{ matrix.website == 'www.ultralytics.com' && secrets.SLACK_WEBHOOK_URL_WEBSITE || secrets.SLACK_WEBHOOK_URL_YOLO }} | ||
payload: | | ||
text: "GitHub Actions: Errors found in ${{ github.workflow }} for ${{ matrix.website }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n\n\n${{ env.SUMMARY }}\n" | ||
- name: Notify Slack for spelling errors | ||
if: always() && steps.codespell.outputs.CODESPELL_FAILED == 'true' && github.event_name == 'schedule' && github.run_attempt == '1' | ||
uses: slackapi/[email protected] | ||
with: | ||
webhook-type: incoming-webhook | ||
webhook: ${{ matrix.website == 'www.ultralytics.com' && secrets.SLACK_WEBHOOK_URL_WEBSITE || secrets.SLACK_WEBHOOK_URL_YOLO }} | ||
payload: | | ||
{ | ||
"text": "GitHub Actions: Spelling errors found in ${{ github.workflow }} for ${{ matrix.website }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n\n\n*Misspelled words:*\n${{ steps.codespell.outputs.CODESPELL_ERRORS }}\n" | ||
} |