Skip to content

Commit

Permalink
Update links.yml (#152)
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Jocher <[email protected]>
  • Loading branch information
glenn-jocher authored Jan 21, 2025
1 parent e7cb915 commit b5c016b
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ name: Check Website links

on:
workflow_dispatch:
pull_request:
schedule:
- cron: "0 0 * * *" # runs at 00:00 UTC every day

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
}

0 comments on commit b5c016b

Please sign in to comment.