Skip to content

Commit 3cb26ea

Browse files
committed
add comments
1 parent 24649cf commit 3cb26ea

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/check-url-changes.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
name: Documentation & Navigation Change Checker
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
branches:
66
- url-test
77

88
jobs:
99
check-doc-nav-changes:
1010
runs-on: ubuntu-latest
1111
steps:
12+
# 1️⃣ Checkout PR branch safely (fork-safe)
1213
- name: Checkout PR branch
1314
uses: actions/checkout@v4
1415
with:
1516
fetch-depth: 0
1617
ref: ${{ github.event.pull_request.head.ref }}
1718
repository: ${{ github.event.pull_request.head.repo.full_name }}
1819

20+
# 2️⃣ Fetch base branch for diffs
1921
- name: Fetch base branch
2022
run: git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
2123

24+
# 3️⃣ Detect deleted, renamed, and modified files
2225
- name: Identify .md and .nav changes
2326
run: |
2427
BASE=origin/${{ github.event.pull_request.base.ref }}
@@ -38,6 +41,7 @@ jobs:
3841
for f in $MODIFIED_NAV; do DIFF=$(git diff $BASE $HEAD -- "$f" | grep -vE '^\+\+\+|^---'); NAV_CHANGES+="$f:\n$DIFF\n\n"; done
3942
for f in $RENAMED_NAV; do NAV_CHANGES+="$f [RENAMED]\n\n"; done
4043
44+
# Export to environment
4145
echo "DELETED_MD<<EOF" >> $GITHUB_ENV
4246
echo "$DELETED_MD" >> $GITHUB_ENV
4347
echo "EOF" >> $GITHUB_ENV
@@ -50,13 +54,15 @@ jobs:
5054
echo -e "$NAV_CHANGES" >> $GITHUB_ENV
5155
echo "EOF" >> $GITHUB_ENV
5256
57+
# Set warning flag
5358
if [ -n "$DELETED_MD$RENAMED_MD$NAV_CHANGES" ]; then
5459
echo "warning=true" >> $GITHUB_ENV
5560
else
5661
echo "warning=false" >> $GITHUB_ENV
5762
fi
5863
59-
- name: Post PR comment if relevant
64+
# 4️⃣ Post PR comment if relevant
65+
- name: Post PR comment
6066
if: env.warning == 'true'
6167
uses: actions/github-script@v7
6268
with:
@@ -66,13 +72,15 @@ jobs:
6672
const renamedMd = `${process.env.RENAMED_MD}`.trim();
6773
const navChanges = `${process.env.NAV_CHANGES}`.trim();
6874
69-
let message = "🔍 **Documentation & Navigation Checker**\n\nThis PR modifies `.md` or `.nav.yml/.nav.yaml` files.\n\n";
75+
// Your requested start message
76+
let message = `🔍 **Documentation URL Checker**\n\nThis PR modifies documentation files in ways that could potentially create broken links.\n\n`;
7077
7178
if (deletedMd) message += `**Deleted Markdown files:**\n\`\`\`\n${deletedMd}\n\`\`\`\n\n`;
7279
if (renamedMd) message += `**Renamed Markdown files:**\n\`\`\`\n${renamedMd}\n\`\`\`\n\n`;
7380
if (navChanges) message += `**Navigation file changes:**\n\`\`\`\n${navChanges}\n\`\`\`\n\n`;
7481
75-
message += "🚨 Please verify:\n- Links are correct\n- TOC matches expected structure\n- Deleted/renamed entries are handled";
82+
// Your requested end message
83+
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`;
7684
7785
github.rest.issues.createComment({
7886
owner: context.repo.owner,

0 commit comments

Comments
 (0)