Skip to content

Commit e612b25

Browse files
committed
amend
Signed-off-by: Aidan Reilly <[email protected]>
1 parent ad0d93f commit e612b25

File tree

5 files changed

+67
-86
lines changed

5 files changed

+67
-86
lines changed

.github/workflows/check-links.yml

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,17 @@ jobs:
1717
sudo apt-get update
1818
sudo apt-get install -y asciidoctor
1919
20-
- name: Make script executable
21-
run: chmod +x scripts/check-links.sh
20+
- name: Make scripts executable
21+
run: |
22+
chmod +x scripts/check-links.sh
23+
chmod +x scripts/check-modified.sh
2224
2325
- name: Fetch base branch
2426
run: git fetch origin main
2527

2628
- name: Check links in modified files
2729
shell: bash
2830
run: |
29-
FILES=$(git diff --name-only origin/main...HEAD --diff-filter=d -- "*.adoc")
30-
31-
check_updated_assemblies () {
32-
MODULES=$(echo "$FILES" | grep '^modules/.*\.adoc$')
33-
ASSEMBLIES=$(echo "$FILES" | grep '^assemblies/.*\.adoc$')
34-
BOOKS=$(echo "$FILES" | grep -E '^[^/]+\.adoc$')
35-
36-
UPDATED_BOOKS=()
37-
38-
if [ -n "$MODULES" ]; then
39-
while IFS= read -r module; do
40-
UPDATED_BOOKS+=( $(grep -rnwl . --include="*.adoc" --exclude-dir={_artifacts,modules,assemblies} -e "$(basename "$module")") )
41-
UPDATED_BOOKS+=( $(grep -rnwl assemblies --include="*.adoc" --exclude-dir={_artifacts,modules} -e "$(basename "$module")") )
42-
done <<< "$MODULES"
43-
fi
44-
45-
if [ -n "$ASSEMBLIES" ]; then
46-
while IFS= read -r assembly; do
47-
UPDATED_BOOKS+=( $(grep -rnwl . --include="*.adoc" --exclude-dir={_artifacts,modules,assemblies} -e "$(basename "$assembly")") )
48-
done <<< "$ASSEMBLIES"
49-
fi
50-
51-
if [ -n "$BOOKS" ]; then
52-
while IFS= read -r book; do
53-
UPDATED_BOOKS+=( "$book" )
54-
done <<< "$BOOKS"
55-
fi
56-
57-
if [ ${#UPDATED_BOOKS[@]} -eq 0 ]; then
58-
echo "No modified books. Skipping link check."
59-
exit 0
60-
fi
61-
62-
for f in "${UPDATED_BOOKS[@]}"; do
63-
./scripts/check-links.sh "$f"
64-
done
65-
}
66-
67-
check_updated_assemblies
31+
scripts/check-modified.sh
6832
6933

assemblies/upgrading-odh-v2.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ include::modules/requirements-for-upgrading-odh-v2.adoc[leveloffset=+1]
2525
include::installing-odh-v2.adoc[leveloffset=+1]
2626

2727
ifdef::parent-context[:context: {parent-context}]
28-
ifndef::parent-context[:!context:]
28+
ifndef::parent-context[:!context:]
29+
30+
https://docs.redhat.com/derp

customizing-models-with-lab-tuning.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ include::assemblies/preparing-lab-tuning-resources.adoc[leveloffset=+1]
2323

2424
include::assemblies/using-lab-tuning.adoc[leveloffset=+1]
2525

26-
https://docs.redhat.com/derp

scripts/check-links-modified.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

scripts/check-modified.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
#
3+
# Checks for 404 links in a compiled list of modified books
4+
5+
ERRORS=0
6+
7+
FILES=$(git diff --name-only origin/main...HEAD --diff-filter=d -- "*.adoc")
8+
9+
MODULES=$(echo "$FILES" | grep '^modules/.*\.adoc$')
10+
ASSEMBLIES=$(echo "$FILES" | grep '^assemblies/.*\.adoc$')
11+
BOOKS=$(echo "$FILES" | grep -E '^[^/]+\.adoc$')
12+
13+
UPDATED_BOOKS=()
14+
15+
if [ -n "$MODULES" ]; then
16+
# Check for assemblies and books that include modified modules
17+
while IFS= read -r module; do
18+
mapfile -t updated_books < <(grep -rnwl . --include="*.adoc" --exclude-dir={_artifacts,modules,assemblies} -e "$(basename "$module")")
19+
UPDATED_BOOKS+=( "${updated_books[@]}" )
20+
21+
mapfile -t updated_books < <(grep -rnwl assemblies --include="*.adoc" --exclude-dir={_artifacts,modules} -e "$(basename "$module")")
22+
UPDATED_BOOKS+=( "${updated_books[@]}" )
23+
done <<< "$MODULES"
24+
fi
25+
26+
# Check for books that include modified assemblies
27+
if [ -n "$ASSEMBLIES" ]; then
28+
while IFS= read -r assembly; do
29+
mapfile -t results3 < <(grep -rnwl . --include="*.adoc" --exclude-dir={_artifacts,modules,assemblies} -e "$(basename "$assembly")")
30+
UPDATED_BOOKS+=( "${results3[@]}" )
31+
done <<< "$ASSEMBLIES"
32+
fi
33+
34+
# Check for directly updated books
35+
if [ -n "$BOOKS" ]; then
36+
while IFS= read -r book; do
37+
UPDATED_BOOKS+=( "$book" )
38+
done <<< "$BOOKS"
39+
fi
40+
41+
if [ ${#UPDATED_BOOKS[@]} -eq 0 ]; then
42+
echo "No modified books. Skipping link check."
43+
exit 0
44+
fi
45+
46+
# Check links in the compiled list of books
47+
48+
for f in "${UPDATED_BOOKS[@]}"; do
49+
echo "Checking: $f"
50+
if ! ./scripts/check-links.sh "$f"; then
51+
echo "❌ Link check failed for: $f"
52+
ERRORS=1
53+
fi
54+
done
55+
56+
if [ "$ERRORS" -ne 0 ]; then
57+
echo "One or more link checks failed."
58+
exit 1
59+
fi

0 commit comments

Comments
 (0)