Test link checker workflow #4
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
name: Link Checker | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
schedule: | |
- cron: '2 0 * * *' | |
jobs: | |
link-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run Lychee link checker on README.md | |
uses: lycheeverse/lychee-action@v1 | |
with: | |
args: --output json ./README.md | |
id: lychee_readme1 | |
- name: Run Lychee link checker on README2.md | |
uses: lycheeverse/lychee-action@v1 | |
with: | |
args: --output json ./README2.md | |
id: lychee_readme2 | |
- name: Check for broken links | |
run: | | |
readme1_output=$(cat ${{ steps.lychee_readme1.outputs.output }}) | |
readme2_output=$(cat ${{ steps.lychee_readme2.outputs.output }}) | |
readme1_broken=$(echo "$readme1_output" | jq '.total.ignored + .total.fail > 0') | |
readme2_broken=$(echo "$readme2_output" | jq '.total.ignored + .total.fail > 0') | |
if [ "$readme1_broken" = "true" ] || [ "$readme2_broken" = "true" ]; then | |
echo "Broken links found in README.md or README2.md" | |
exit 1 | |
else | |
echo "No broken links found" | |
fi | |
- name: Notify user of broken links | |
if: failure() | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 587 | |
username: ${{ secrets.GMAIL_USERNAME }} | |
password: ${{ secrets.GMAIL_PASSWORD }} | |
subject: Broken links detected in README files | |
body: 'Broken links were detected in the README files. Please check the workflow logs for details.' | |
to: [email protected] | |
from: [email protected] |