1
1
#! /bin/bash
2
- # Returns a list of page preview URLs
2
+ # Returns a list of page preview URLs for use with Prow CI jobs
3
+ # To run locally, clean the _preview folder and do a new asciibinder build before running the script
3
4
4
5
# Check if jq is installed
5
6
hash jq 2> /dev/null || { echo >&2 " Error: jq is not installed" ; exit 1; }
@@ -13,7 +14,7 @@ assemblies=()
13
14
pages=()
14
15
files=$( git diff --name-only HEAD~1 HEAD --diff-filter=AMRD " *.adoc" ' :(exclude)_unused_topics/*' )
15
16
16
- # Get the full list of built files
17
+ # Get the full list of HTML build files
17
18
if [ -e " _preview" ]; then
18
19
built_pages=$( find _preview -type f -name " *.html" -printf " %P\n" )
19
20
else
@@ -27,14 +28,17 @@ for file in $files; do
27
28
assemblies+=(" $found_file " )
28
29
done
29
30
30
- # Make the html URL slug
31
+ # Make the HTML URL slug
31
32
if [ ${# assemblies[@]} -gt 0 ]; then
32
33
updated_pages=$( echo " ${assemblies[@]} " | xargs -n1 basename | sed ' s/\.adoc$/.html/' | sort | uniq)
34
+ else
35
+ # No updated pages, just add default URL
36
+ pages+=(" ${preview_url} " )
33
37
fi
34
38
35
39
# Search built_pages for every entry in updated_pages and add to pages array when it is found
36
40
for updated_page in $updated_pages ; do
37
- # Note also need to sed $pr_branch > "latest"
41
+ # sed $pr_branch > "latest" to match the Prow build URL
38
42
found_page=$( echo " ${built_pages} " | grep " ${updated_page} " | sed " s/$pr_branch /latest/" )
39
43
pages+=(" ${preview_url} /${found_page} " )
40
44
done
0 commit comments