Skip to content

Commit 49a60d6

Browse files
committed
More efficient use of jq.
1 parent a8f4df5 commit 49a60d6

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

.github/workflows/render.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ jobs:
8686
if echo "${input}" | jq -e '.append_git_rev_to_version' > /dev/null; then
8787
echo "Appending git rev to version string in ${src}"
8888
89-
# The sed command handles the following transformations:
9089
# `version: 1.3` --> `version: 1.3 (Git commit xyz)`
9190
# `version: "2.0"` --> `version: "2.0 (Git commit xyz)"`
9291
sed -i -r "/^---$/,/^---$/s/^(version: \"?[^\"]*)(\"?)$/\1 (Git commit ${commit_hash})\2/g" "${src}"
9392
fi
9493
95-
if echo "${input}" | jq -e 'has("gh_pages_html")' > /dev/null; then
96-
gh_pages_html=$(echo "${input}" | jq -r '.gh_pages_html')
97-
94+
gh_pages_html=$(echo "${input}" | jq -e -r '.gh_pages_html')
95+
if [ $? -eq 0 ]; then
9896
echo "Rendering ${src} to gh-pages/${gh_pages_html}/index.html"
9997
10098
(cd "${src_dirname}" && exec \
@@ -113,9 +111,8 @@ jobs:
113111
mv "${src_dirname}/index.html" "gh-pages/${gh_pages_html}/"
114112
fi
115113
116-
if echo "${input}" | jq -e 'has("gh_pages_pdf")' > /dev/null; then
117-
gh_pages_pdf=$(echo "${input}" | jq -r '.gh_pages_pdf')
118-
114+
gh_pages_pdf=$(echo "${input}" | jq -e -r '.gh_pages_pdf')
115+
if [ $? -eq 0 ]; then
119116
# [parent dir name]_[filename sans extension]_[git commit hash].pdf
120117
pdf_name="$(basename "${src_dirname}")_${src_basename%.*}_${commit_hash}.pdf"
121118

0 commit comments

Comments
 (0)