Skip to content

Commit 467b2fe

Browse files
committed
update preview URL script
1 parent 2173285 commit 467b2fe

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/get-updated-preview-urls.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/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
34

45
# Check if jq is installed
56
hash jq 2>/dev/null || { echo >&2 "Error: jq is not installed"; exit 1; }
@@ -13,7 +14,7 @@ assemblies=()
1314
pages=()
1415
files=$(git diff --name-only HEAD~1 HEAD --diff-filter=AMRD "*.adoc" ':(exclude)_unused_topics/*')
1516

16-
# Get the full list of built files
17+
# Get the full list of HTML build files
1718
if [ -e "_preview" ]; then
1819
built_pages=$(find _preview -type f -name "*.html" -printf "%P\n")
1920
else
@@ -27,14 +28,17 @@ for file in $files; do
2728
assemblies+=("$found_file")
2829
done
2930

30-
# Make the html URL slug
31+
# Make the HTML URL slug
3132
if [ ${#assemblies[@]} -gt 0 ]; then
3233
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}")
3337
fi
3438

3539
# Search built_pages for every entry in updated_pages and add to pages array when it is found
3640
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
3842
found_page=$(echo "${built_pages}" | grep "${updated_page}" | sed "s/$pr_branch/latest/")
3943
pages+=("${preview_url}/${found_page}")
4044
done

0 commit comments

Comments
 (0)