Skip to content

Commit 24caa34

Browse files
authored
Merge pull request #84399 from aireilly/new-portal-build-script
Adding new script for bccutil portal scratch build
2 parents 6dc45bc + ef1e8c8 commit 24caa34

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

scripts/get-updated-portal-books.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# Returns a list of updated portal books
3+
# To run locally or in Prow CI:
4+
# ./get-updated-portal-books.sh
5+
6+
# Check if jq is installed
7+
hash jq 2>/dev/null || { echo >&2 "Error: jq is not installed"; exit 1; }
8+
9+
assemblies=()
10+
updated_books=()
11+
files=$(git diff --name-only HEAD~1 HEAD --diff-filter=AMRD "*.adoc" ':(exclude)_unused_topics/*')
12+
13+
# Get the full list of master.adoc files in the drupal-build/ folder
14+
if [ -e "drupal-build" ]; then
15+
master_files=$(find drupal-build -type f -name "master.adoc" -printf "drupal-build/%P\n")
16+
else
17+
echo "drupal-build output folder not found"
18+
exit 1
19+
fi
20+
21+
# Search for $file references in all *.adoc files that are not in a folder called modules/, snippets/, or _unused_topics/
22+
for file in $files; do
23+
include_ref="include::$file"
24+
found_file=$(grep -rl --include='*.adoc' --exclude-dir={modules,snippets,_unused_topics} "^$include_ref")
25+
# Add the found updated assemblies, not directly included in PR
26+
assemblies+=("$found_file")
27+
# If not found, then it is a directly updated assembly file
28+
if [ -z "$found_file" ]; then
29+
assemblies+=("$file")
30+
fi
31+
done
32+
33+
# Construct the drupal-build master.adoc folder paths
34+
if [ ${#assemblies[@]} -gt 0 ]; then
35+
for assembly in "${assemblies[@]}"; do
36+
updated_master_files+=$(echo "$assembly" | awk -F'/' '{print "drupal-build/openshift-enterprise/" $1 "/master.adoc"}' | tr '\n' ' ')
37+
done
38+
fi
39+
40+
# Search master_files for every entry in updated_master_files and add to updated_books array when it is found
41+
for master_file in $updated_master_files; do
42+
updated_book=$(echo "${master_files}" | grep "${master_file}")
43+
updated_books+=("${updated_book}")
44+
done
45+
46+
# Echo the updated master.adoc files
47+
echo "${updated_books[@]}" | tr ' ' '\n' | sort | uniq

0 commit comments

Comments
 (0)