Skip to content

Commit 3cef4f1

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

File tree

5 files changed

+55
-86
lines changed

5 files changed

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

0 commit comments

Comments
 (0)