44 pull_request :
55 branches :
66 - master
7+ paths :
8+ - ' **/*.md'
9+ - ' **/*.nav.yml'
10+ - ' !**/.*.yml'
11+ - ' !**/.*.yaml'
712
813jobs :
914 check-url-changes :
@@ -14,43 +19,52 @@ jobs:
1419 with :
1520 fetch-depth : 0
1621
17- - name : Identify deleted and renamed files
22+ - name : Identify deleted, renamed, and nav changes
1823 run : |
19- # Store deleted files
24+ # Deleted markdown files
2025 DELETED_FILES=$(git diff --name-status origin/master ${{ github.event.pull_request.head.sha }} | grep '^D.*\.md$' | cut -f2- || true)
2126 echo "DELETED_FILES<<EOF" >> $GITHUB_ENV
2227 echo "$DELETED_FILES" >> $GITHUB_ENV
2328 echo "EOF" >> $GITHUB_ENV
2429
25- # Store renamed/moved files
30+ # Renamed markdown files
2631 RENAMED_FILES=$(git diff --name-status origin/master ${{ github.event.pull_request.head.sha }} | grep '^R.*\.md$' | awk '{print $2 " -> " $3}' || true)
2732 echo "RENAMED_FILES<<EOF" >> $GITHUB_ENV
2833 echo "$RENAMED_FILES" >> $GITHUB_ENV
2934 echo "EOF" >> $GITHUB_ENV
35+
36+ # Nav file changes (mkdocs.yml or *.nav.yml/yaml only)
37+ NAV_FILES=$(git diff --name-only origin/master ${{ github.event.pull_request.head.sha }} | grep -E '(mkdocs\.yml$|\.nav\.ya?ml$)' | grep -vE '/\.[^/]+\.ya?ml$' || true)
38+
39+ NAV_CHANGES=""
40+ for FILE in $NAV_FILES; do
41+ DIFF=$(git diff origin/master ${{ github.event.pull_request.head.sha }} -- "$FILE" | grep -vE '^\+\+\+|^---' || true)
42+ if [ ! -z "$DIFF" ]; then
43+ NAV_CHANGES+="$FILE:\n$DIFF\n\n"
44+ fi
45+ done
46+
47+ echo "NAV_CHANGES<<EOF" >> $GITHUB_ENV
48+ echo -e "$NAV_CHANGES" >> $GITHUB_ENV
49+ echo "EOF" >> $GITHUB_ENV
3050
31- # Set warning flag if there are any changes
32- if [ ! -z "$DELETED_FILES" ] || [ ! -z "$RENAMED_FILES" ]; then
51+ # Set warning flag if anything risky is found
52+ if [ -n "$DELETED_FILES" ] || [ -n "$RENAMED_FILES" ] || [ -n "$NAV_CHANGES " ]; then
3353 echo "warning=true" >> $GITHUB_ENV
3454 else
3555 echo "warning=false" >> $GITHUB_ENV
3656 fi
37-
38- # Print to console for logging
39- echo "Deleted files:"
40- echo "$DELETED_FILES"
41- echo -e "\nRenamed/Moved files:"
42- echo "$RENAMED_FILES"
4357
4458 - name : Post PR warning
4559 if : env.warning == 'true'
4660 uses : actions/github-script@v7
4761 with :
48- github-token : ${{ secrets.GITHUB_TOKEN }}
4962 script : |
5063 const issue_number = context.payload.pull_request.number;
5164 const repo = context.repo;
5265 const deletedFiles = `${process.env.DELETED_FILES}`.trim();
5366 const renamedFiles = `${process.env.RENAMED_FILES}`.trim();
67+ const navChanges = `${process.env.NAV_CHANGES}`.trim();
5468
5569 let message = `🔍 **Documentation URL Checker**\n\nThis PR modifies documentation files in ways that could potentially create broken links.\n\n`;
5670
@@ -61,12 +75,16 @@ jobs:
6175 if (renamedFiles) {
6276 message += `**Renamed/Moved files:**\n\`\`\`\n${renamedFiles}\n\`\`\`\n\n`;
6377 }
78+
79+ if (navChanges) {
80+ message += `**Modified navigation files (possible URL changes):**\n\`\`\`\n${navChanges}\n\`\`\`\n\n`;
81+ }
6482
65- message += `🚨 Please review these changes carefully 🚨\n\n If not handled properly, broken links (404 errors) could appear. To maintain a smooth user experience, consider:\n- Adding redirects in the \`mkdocs.yml\` file from the old URLs to the new ones\n- Updating internal references to these files`;
83+ message += `🚨 Please review these changes carefully 🚨\n\nIf not handled properly, broken links (404 errors) could appear. To maintain a smooth user experience, consider:\n- Adding redirects in the \`mkdocs.yml\` file from the old URLs to the new ones\n- Updating internal references to these files\n- Verifying that the navigation structure still matches the intended URLs. `;
6684
6785 github.rest.issues.createComment({
6886 owner: repo.owner,
6987 repo: repo.repo,
7088 issue_number: issue_number,
7189 body: message
72- });
90+ });
0 commit comments