Skip to content

Commit fa47688

Browse files
committed
fix: handle missing .adoc files in docs workflow
- Check if .adoc files exist before attempting conversion - Skip conversion step gracefully if no .adoc files found - Handle case where no changes need to be committed - Update commit message to be more generic - Fixes exit code 123 error when no .adoc files are present
1 parent e78cb7c commit fa47688

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

.github/workflows/gh-pages.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ jobs:
4545

4646
- name: Converting AsciiDoc files to HTML
4747
run: |
48-
find . -name "*.adoc" | xargs asciidoctor -b html --attribute=nofooter
49-
for FILE in `find . -name "README.html"`; do
50-
mv "$FILE" "`dirname $FILE`/index.html";
51-
done
52-
for FILE in `find . -name "*.html"`; do
53-
git add -f "$FILE";
54-
done
55-
find . -name "*.adoc" | xargs git rm -f --cached
48+
if find . -name "*.adoc" -print -quit | grep -q .; then
49+
find . -name "*.adoc" -print0 | xargs -0 asciidoctor -b html --attribute=nofooter
50+
for FILE in `find . -name "README.html"`; do
51+
mv "$FILE" "`dirname $FILE`/index.html";
52+
done
53+
for FILE in `find . -name "*.html"`; do
54+
git add -f "$FILE";
55+
done
56+
find . -name "*.adoc" -print0 | xargs -0 git rm -f --cached
57+
else
58+
echo "No .adoc files found, skipping AsciiDoc conversion"
59+
fi
5660
shell: bash
5761

5862
- name: Remove irrelevant files from gh-pages branch
@@ -70,8 +74,12 @@ jobs:
7074
- name: Commiting changes to gh-pages branch
7175
if: ${{ ! contains(github.actor, '/act') }}
7276
run: |
73-
MSG="Build .adoc files for GitHub Pages from commit `cat /tmp/commit-hash.txt`"
74-
git -c user.name="Github Action" -c user.email="github-actions@github.com" commit -m "$MSG" 1>/dev/null
75-
set -x
76-
git push -f --verbose --set-upstream origin gh-pages 1>/dev/null
77+
MSG="Build documentation for GitHub Pages from commit `cat /tmp/commit-hash.txt`"
78+
if git diff --quiet --cached; then
79+
echo "No changes to commit, skipping commit and push"
80+
else
81+
git -c user.name="Github Action" -c user.email="github-actions@github.com" commit -m "$MSG" 1>/dev/null
82+
set -x
83+
git push -f --verbose --set-upstream origin gh-pages 1>/dev/null
84+
fi
7785
shell: bash

0 commit comments

Comments
 (0)