Skip to content

Commit 50f1f06

Browse files
committed
Test
1 parent 557d351 commit 50f1f06

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
name: Documentation & Navigation Change Checker
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
branches:
6-
- url-test # target branch
6+
- 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)
12+
# 1️⃣ Checkout PR branch
1313
- name: Checkout PR branch
1414
uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717
ref: ${{ github.event.pull_request.head.ref }}
1818
repository: ${{ github.event.pull_request.head.repo.full_name }}
1919

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

24-
# 3️⃣ Detect .md and .nav changes
25-
- name: Identify changed files
24+
# 3️⃣ Identify .md and .nav changes
25+
- name: Identify .md and .nav changes
2626
run: |
2727
BASE=origin/${{ github.event.pull_request.base.ref }}
2828
HEAD=${{ github.event.pull_request.head.sha }}
2929
3030
# Detect any relevant changes
31-
CHANGED_MD=$(git diff --name-status $BASE $HEAD | grep -E '^([ADM]|R).*\.md$' || true)
32-
CHANGED_NAV=$(git diff --name-status $BASE $HEAD | grep -E '^([ADM]|R).*\.nav\.ya?ml$' || true)
31+
CHANGED_FILES=$(git diff --name-status $BASE $HEAD | grep -E '\.md$|\.nav\.ya?ml$' || true)
3332
3433
# Exit early if no relevant files changed
35-
if [ -z "$CHANGED_MD$CHANGED_NAV" ]; then
34+
if [ -z "$CHANGED_FILES" ]; then
3635
echo "No .md or .nav.yml/.nav.yaml changes detected. Exiting."
3736
exit 0
3837
fi
3938
40-
# Prepare environment variables
41-
DELETED_MD=$(echo "$CHANGED_MD" | grep '^D' | cut -f2- || true)
42-
RENAMED_MD=$(echo "$CHANGED_MD" | grep '^R' | awk '{print $2 " -> " $3}' || true)
39+
# 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)
4342
44-
DELETED_NAV=$(echo "$CHANGED_NAV" | grep '^D' | cut -f2- || true)
45-
MODIFIED_NAV=$(echo "$CHANGED_NAV" | grep '^A\|^M' | cut -f2- || true)
46-
RENAMED_NAV=$(echo "$CHANGED_NAV" | grep '^R' | awk '{print $2 " -> " $3}' || true)
43+
# 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)
4747
4848
NAV_CHANGES=""
49-
5049
for f in $DELETED_NAV; do NAV_CHANGES+="$f: [DELETED]\n\n"; done
5150
for f in $MODIFIED_NAV; do DIFF=$(git diff $BASE $HEAD -- "$f" | grep -vE '^\+\+\+|^---'); NAV_CHANGES+="$f:\n$DIFF\n\n"; done
5251
for f in $RENAMED_NAV; do NAV_CHANGES+="$f [RENAMED]\n\n"; done
5352
53+
# Export env variables
5454
echo "DELETED_MD<<EOF" >> $GITHUB_ENV
5555
echo "$DELETED_MD" >> $GITHUB_ENV
5656
echo "EOF" >> $GITHUB_ENV
@@ -63,6 +63,7 @@ jobs:
6363
echo -e "$NAV_CHANGES" >> $GITHUB_ENV
6464
echo "EOF" >> $GITHUB_ENV
6565
66+
# Set warning flag
6667
echo "warning=true" >> $GITHUB_ENV
6768
6869
# 4️⃣ Post PR comment if relevant
@@ -76,15 +77,13 @@ jobs:
7677
const renamedMd = `${process.env.RENAMED_MD}`.trim();
7778
const navChanges = `${process.env.NAV_CHANGES}`.trim();
7879
79-
// ✅ Requested intro
80-
let message = `🔍 **Documentation URL Checker**\n\nThis PR modifies documentation files in ways that could potentially create broken links.\n\n`;
80+
let message = "🔍 **Documentation URL Checker**\n\nThis PR modifies documentation files in ways that could potentially create broken links.\n\n";
8181
8282
if (deletedMd) message += `**Deleted Markdown files:**\n\`\`\`\n${deletedMd}\n\`\`\`\n\n`;
8383
if (renamedMd) message += `**Renamed Markdown files:**\n\`\`\`\n${renamedMd}\n\`\`\`\n\n`;
8484
if (navChanges) message += `**Navigation file changes:**\n\`\`\`\n${navChanges}\n\`\`\`\n\n`;
8585
86-
// ✅ Requested closing
87-
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`;
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";
8887
8988
github.rest.issues.createComment({
9089
owner: context.repo.owner,

0 commit comments

Comments
 (0)