Skip to content

Commit 3b2e977

Browse files
committed
Change pr.yml to ignore code blocks + inline code, only match real text
1 parent 147307c commit 3b2e977

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

.github/workflows/pr.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: yarn install --frozen-lockfile
3737
- name: Build the Docusaurus site
3838
run: yarn build
39-
# --- NEW: Disallowed character checks for Pantheon ---
39+
# --- Disallowed character checks for Pantheon ---
4040
# 1) Fail if any file path in the build output contains disallowed characters
4141
- name: Check build artifact paths for disallowed characters
4242
env:
@@ -55,14 +55,14 @@ jobs:
5555
while IFS= read -r p; do
5656
rel="${p#$(pwd)/}"
5757
[ "$rel" = "$p" ] && rel="$p"
58-
# Detect and print which character(s) caused it
5958
badchars=$(echo "$rel" | grep -oE '[":<>|*?]' | tr -d '\n')
6059
echo "::error file=${rel}::Disallowed character(s) found in build artifact path: [${badchars}] (Pantheon rejects paths containing any of: \" : < > | * ?)"
6160
done <<< "$OFFENDERS"
6261
exit 1
6362
fi
6463
echo "✅ No disallowed characters found in build artifact paths."
65-
# 2) Fail if any Markdown/MDX link target contains disallowed characters (excluding external links)
64+
# 2) Fail if any Markdown/MDX link target contains disallowed characters (excluding external links).
65+
# Ignores fenced code blocks (```/~~~) and inline code (`...`) to avoid false positives from code samples.
6666
- name: Check Markdown/MDX links for disallowed characters
6767
shell: bash
6868
run: |
@@ -73,28 +73,43 @@ jobs:
7373
fi
7474
BAD_LINKS=$(
7575
awk '
76+
BEGIN { in_code=0 }
7677
{
77-
line=$0
78-
while (match(line, /\]\(([^)]+)\)/, m)) {
78+
raw=$0
79+
80+
# Toggle fenced code blocks starting with ``` or ~~~
81+
if (match(raw, /^\s*(```|~~~)/)) { in_code = !in_code; next }
82+
if (in_code) { next }
83+
84+
# Strip inline code spans so patterns inside don’t trigger
85+
line = raw
86+
gsub(/`[^`]*`/, "", line)
87+
88+
# Find real Markdown links: [text](url)
89+
while (match(line, /\[[^]]+\]\(([^)]+)\)/, m)) {
7990
url=m[1]
80-
# skip external schemes
91+
92+
# Skip external schemes
8193
if (url ~ /^(https?:|mailto:|tel:)/) { line=substr(line, RSTART+RLENGTH); continue }
82-
# drop query + fragment
94+
95+
# Drop query + fragment
8396
sub(/\?.*$/, "", url)
8497
sub(/#.*/, "", url)
85-
# flag if contains disallowed characters: " : < > | * ?
98+
99+
# Disallowed characters in relative link targets: " : < > | * ?
86100
if (url ~ /[":<>|*?]/) {
87101
printf("%s\t%d\t%s\n", FILENAME, FNR, m[0])
88102
}
103+
89104
line=substr(line, RSTART+RLENGTH)
90105
}
91106
}
92107
' $FILES
93108
)
109+
94110
if [ -n "$BAD_LINKS" ]; then
95111
echo "❌ Disallowed characters found in Markdown/MDX link targets:"
96112
echo "$BAD_LINKS"
97-
# Emit GitHub annotations for each finding (including exact bad char(s))
98113
while IFS=$'\t' read -r file line match; do
99114
[ -z "$file" ] && continue
100115
badchars=$(echo "$match" | grep -oE '[":<>|*?]' | tr -d '\n')

docs/platform-services/automation-service/app-central/integrations/atlassian-jira-v2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ import AccessKey from '../../../../reuse/automation-service/access-key.md';
9292

9393
<img src={useBaseUrl('/img/platform-services/automation-service/app-central/integrations/atlassian-jira-v2/atlassian-jira-v2-5.png')} style={{border:'1px solid gray'}} alt="atlassian-jira-v2-5" width="400"/>
9494

95-
For information about Atlassian Jira, see [Jira documentation]( https://confluence.atlassian.com/jira). For the REST API v2, see the [REST API v2 documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/).
95+
For information about Atlassian Jira, see [Jira documentation](https://confluence.atlassian.com/jira). For the REST API v2, see the [REST API v2 documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/).
9696

9797
## Category
9898

docs/platform-services/automation-service/app-central/integrations/atlassian-jira.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import AccessKey from '../../../../reuse/automation-service/access-key.md';
6666

6767
<img src={useBaseUrl('/img/platform-services/automation-service/app-central/integrations/atlassian/atlassian-jira-configuration.png')} style={{border:'1px solid gray'}} alt="Atlassian Jira Logger configuration" width="400"/>
6868

69-
For information about Atlassian Jira, see [Jira documentation]( https://confluence.atlassian.com/jira).
69+
For information about Atlassian Jira, see [Jira documentation](https://confluence.atlassian.com/jira).
7070

7171
## Change Log
7272

0 commit comments

Comments
 (0)