Skip to content

Commit

Permalink
BAU: Check for broken external links
Browse files Browse the repository at this point in the history
Sometimes pages disappear from the internet or move, and we want to keep our outbound links in good condition. We sleep between requests to GitHub to avoid being rate-limited, and ignore some specific repositories which will fail the link checker.
  • Loading branch information
mrwilson committed Apr 26, 2023
1 parent c8f729c commit b77f928
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@

after_build do |builder|
begin
HTMLProofer.check_directory(config[:build_dir],
proofer = HTMLProofer.check_directory(config[:build_dir],
{ :assume_extension => true,
:disable_external => true,
:allow_hash_href => true,
:empty_alt_ignore => true,
:file_ignore => [
/search/ # Provided by tech-docs gem but has a "broken" link from html-proofer's point of view
],
:url_ignore => [
"https://github.com/alphagov/centralised-security-logging-service"
]
}).run
})

proofer.before_request do |request|
# We get rate-limited by GitHub so pause between checking GitHub links
sleep 2 if request.base_url == "https://github.com/"
end

proofer.run
rescue RuntimeError => e
abort e.to_s
end
Expand Down

0 comments on commit b77f928

Please sign in to comment.