-
Notifications
You must be signed in to change notification settings - Fork 284
Check for 404 redirect URLs #2190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d240f63
add new redirects
nprt 6fb5170
add redirect everything
nprt 8ea4e70
create direct community redirects
nprt b5cc6f4
add a 404 url checker script
nprt 2feae33
Merge branch 'polkadot-developers:main' into main
nprt b81ee88
read urls from netlify redirects
nprt fd65411
Merge branch 'main' of github.com:nprt/substrate-docs
nprt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
# Takes a list of docs.substrate.io URLs from the netlify _redirects file, | ||
# and checks which of them return 404 response code after following redirects. | ||
|
||
# Check if curl is installed | ||
if ! command -v curl &> /dev/null; then | ||
echo "::error::Error: curl is required but not installed" | ||
exit 1 | ||
fi | ||
|
||
# Check if input file is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "::error::Usage: $0 <url_list_file>" | ||
echo "::error::url_list_file: Invalid number of arguments" | ||
exit 1 | ||
fi | ||
|
||
input_file="$1" | ||
|
||
# Check if input file exists | ||
if [ ! -f "$input_file" ]; then | ||
echo "::error::Error: File '$input_file' not found" | ||
exit 1 | ||
fi | ||
|
||
# Process each URL | ||
echo "::warning::The following polkadot.com URLs are missing:" | ||
while IFS= read -r line || [ -n "$line" ]; do | ||
# Skip empty lines | ||
[ -z "$line" ] && continue | ||
|
||
# Extract path and destination | ||
path=$(echo "$line" | awk '{print $1}' | xargs) | ||
destination=$(echo "$line" | awk '{print $2}' | xargs) | ||
source_url="https://docs.substrate.io${path}" | ||
|
||
# Get HTTP response code with timeout, following redirects | ||
response=$(curl -L -o /dev/null -s -w "%{http_code}" -m 10 "$destination") | ||
|
||
if [ "$response" = "404" ]; then | ||
echo "::warning::$destination" | ||
fi | ||
done < "$input_file" |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
name: Check Redirect 404s | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
inputs: | ||
redirect_file: | ||
description: 'Redirect file to check' | ||
required: true | ||
type: string | ||
default: '.github/scripts/polkadot_com_redirects' | ||
schedule: | ||
- cron: '0 14 * * 1' # Every Monday at 2pm UTC | ||
|
||
jobs: | ||
check-redirects: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run redirect checker | ||
run: .github/scripts/find_redirect_404s.sh .netlify/_redirects |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ain't going fail/report anywhere?
may be collect 404s into array and if it's empty exit 0, if there are elements 1 ?
alternatively send an email/matrix message to room?
otherwise im curious how will we not forget to check and analyze it periodically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RemyLeBerre and I have a recurring weekly call to go over this together (it's one of the call topics). It's a temporary check, and I expect we'll archive the repository/project before we stop having the call.
I'd rather we try to avoid adding any integrations, since it's going to be decommissioned pretty soon. I think the same goes for the error code/status. I'd prefer classifying it as a warning, since it's not really a redirect error, and will be fixed on the other side (polkadot.com). This is more a source of information, rather than a trigger to do something in this repo.