Skip to content

Commit 9568f0a

Browse files
committed
Test
1 parent f9146d8 commit 9568f0a

File tree

1 file changed

+15
-40
lines changed

1 file changed

+15
-40
lines changed
Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,50 @@
11
name: Documentation & Navigation Change Checker
2-
32
on:
43
pull_request:
54
branches:
65
- url-test
7-
86
jobs:
97
check-doc-nav-changes:
108
runs-on: ubuntu-latest
119
steps:
12-
# 1️⃣ Checkout PR branch
1310
- name: Checkout PR branch
1411
uses: actions/checkout@v4
1512
with:
1613
fetch-depth: 0
1714
ref: ${{ github.event.pull_request.head.ref }}
1815
repository: ${{ github.event.pull_request.head.repo.full_name }}
19-
20-
# 2️⃣ Fetch base branch for diffs
2116
- name: Fetch base branch
2217
run: git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
23-
24-
# 3️⃣ Identify .md and .nav changes
2518
- name: Identify .md and .nav changes
2619
run: |
2720
BASE=origin/${{ github.event.pull_request.base.ref }}
2821
HEAD=${{ github.event.pull_request.head.sha }}
29-
30-
# Detect any relevant changes
31-
CHANGED_FILES=$(git diff --name-status $BASE $HEAD | grep -E '\.md$|\.nav\.ya?ml$' || true)
32-
33-
# Exit early if no relevant files changed
34-
if [ -z "$CHANGED_FILES" ]; then
35-
echo "No .md or .nav.yml/.nav.yaml changes detected. Exiting."
36-
exit 0
37-
fi
38-
3922
# Markdown changes
40-
DELETED_MD=$(echo "$CHANGED_FILES" | grep '^D.*\.md$' | cut -f2- || true)
41-
RENAMED_MD=$(echo "$CHANGED_FILES" | grep '^R.*\.md$' | awk '{print $2 " -> " $3}' || true)
42-
23+
DELETED_MD=$(git diff --name-status $BASE $HEAD | grep '^D.*\.md$' | cut -f2- || true)
24+
RENAMED_MD=$(git diff --name-status $BASE $HEAD | grep '^R.*\.md$' | awk '{print $2 " -> " $3}' || true)
4325
# Nav changes
44-
DELETED_NAV=$(echo "$CHANGED_FILES" | grep '^D.*\.nav\.ya?ml$' | cut -f2- || true)
45-
MODIFIED_NAV=$(echo "$CHANGED_FILES" | grep '^A\|^M.*\.nav\.ya?ml$' | cut -f2- || true)
46-
RENAMED_NAV=$(echo "$CHANGED_FILES" | grep '^R.*\.nav\.ya?ml$' | awk '{print $2 " -> " $3}' || true)
47-
26+
DELETED_NAV=$(git diff --name-status $BASE $HEAD | grep '^D.*\.nav\.ya?ml$' | cut -f2- || true)
27+
MODIFIED_NAV=$(git diff --name-status $BASE $HEAD | grep -E '^[AM].*\.nav\.ya?ml$' | cut -f2- || true)
28+
RENAMED_NAV=$(git diff --name-status $BASE $HEAD | grep '^R.*\.nav\.ya?ml$' | awk '{print $2 " -> " $3}' || true)
4829
NAV_CHANGES=""
4930
for f in $DELETED_NAV; do NAV_CHANGES+="$f: [DELETED]\n\n"; done
5031
for f in $MODIFIED_NAV; do DIFF=$(git diff $BASE $HEAD -- "$f" | grep -vE '^\+\+\+|^---'); NAV_CHANGES+="$f:\n$DIFF\n\n"; done
5132
for f in $RENAMED_NAV; do NAV_CHANGES+="$f [RENAMED]\n\n"; done
52-
53-
# Export env variables
5433
echo "DELETED_MD<<EOF" >> $GITHUB_ENV
5534
echo "$DELETED_MD" >> $GITHUB_ENV
5635
echo "EOF" >> $GITHUB_ENV
57-
5836
echo "RENAMED_MD<<EOF" >> $GITHUB_ENV
5937
echo "$RENAMED_MD" >> $GITHUB_ENV
6038
echo "EOF" >> $GITHUB_ENV
61-
6239
echo "NAV_CHANGES<<EOF" >> $GITHUB_ENV
6340
echo -e "$NAV_CHANGES" >> $GITHUB_ENV
6441
echo "EOF" >> $GITHUB_ENV
65-
66-
# Set warning flag
67-
echo "warning=true" >> $GITHUB_ENV
68-
69-
# 4️⃣ Post PR comment if relevant
70-
- name: Post PR comment
42+
if [ -n "$DELETED_MD$RENAMED_MD$NAV_CHANGES" ]; then
43+
echo "warning=true" >> $GITHUB_ENV
44+
else
45+
echo "warning=false" >> $GITHUB_ENV
46+
fi
47+
- name: Post PR comment if relevant
7148
if: env.warning == 'true'
7249
uses: actions/github-script@v7
7350
with:
@@ -76,18 +53,16 @@ jobs:
7653
const deletedMd = `${process.env.DELETED_MD}`.trim();
7754
const renamedMd = `${process.env.RENAMED_MD}`.trim();
7855
const navChanges = `${process.env.NAV_CHANGES}`.trim();
79-
80-
let message = "🔍 **Documentation URL Checker**\n\nThis PR modifies documentation files in ways that could potentially create broken links.\n\n";
81-
56+
let message = "🔍 **Documentation & Navigation Checker**\n\nThis PR modifies `.md` or `.nav.yml/.nav.yaml` files.\n\n";
8257
if (deletedMd) message += `**Deleted Markdown files:**\n\`\`\`\n${deletedMd}\n\`\`\`\n\n`;
8358
if (renamedMd) message += `**Renamed Markdown files:**\n\`\`\`\n${renamedMd}\n\`\`\`\n\n`;
8459
if (navChanges) message += `**Navigation file changes:**\n\`\`\`\n${navChanges}\n\`\`\`\n\n`;
8560
86-
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";
87-
61+
message += "🚨 Please verify:\n- Links are correct\n- TOC matches expected structure\n- Deleted/renamed entries are handled. \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";
62+
8863
github.rest.issues.createComment({
8964
owner: context.repo.owner,
9065
repo: context.repo.repo,
9166
issue_number: context.payload.pull_request.number,
9267
body: message
93-
});
68+
});

0 commit comments

Comments
 (0)