Skip to content

Check Links #53

Check Links

Check Links #53

Workflow file for this run

name: Check Links
on:
workflow_dispatch:
pull_request:
schedule:
- cron: "0 0 * * 0" # Runs weekly at 00:00 on Sundays
jobs:
check_links:
name: Check Links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Run awesome_bot checks
run: |
gem install awesome_bot
awesome_bot README.md --allow-redirect --allow 403
- name: Create issue for broken links
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for entry in $(cat ab-results-README.md-filtered.json | jq -r '.[] | @base64'); do
link=$(echo "$entry" | base64 --decode | jq -r '.link')
status=$(echo "$entry" | base64 --decode | jq -r '.status')
error=$(echo "$entry" | base64 --decode | jq -r '.error')
if [ -z "$error" ]; then
error="$status"
fi
issue_exists=$(gh issue list --state "open" --search "Broken link: $link" | wc -l)
if [ "$issue_exists" -eq 0 ]; then
# Markdown table with link and error columns
body="[awesome_bot](https://github.com/dkhamsing/awesome_bot) found the following broken link:
| Link | Status/Error |
| ---- | ----- |
| $link | $error |"
gh issue create --title "Broken link: $link" --body "$body"
else
echo "Issue already exists for link: $link"
fi
done