Skip to content

Commit

Permalink
Create adoc PR builder [DOC-243]
Browse files Browse the repository at this point in the history
  • Loading branch information
JackPGreen committed Nov 23, 2024
1 parent 8fabadb commit d9bccb9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/actions/test-adoc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test asciidoctor files

env:
# Not possible to set this as a default
# https://github.com/orgs/community/discussions/46670
shell: bash

runs:
using: composite

steps:
- name: Install asciidoctor
shell: ${{ env.shell }}
run: |
sudo apt-get update
sudo apt-get install -y asciidoctor
- name: Check for errors
shell: ${{ env.shell }}
run: |
# Builds the adoc file using asciidoctor, discarding the output
# This logs any warnings etc
# asciidoc doesn't handle "include::partial" (this is supported by Antora on top), so we ignore any of those errors
# We can't use Antora directly because if built in isolation, none of the links between documentation repos resolve
# To address this would require comingling PR and upstream repos
output=$( \
asciidoctor \
--out-file /dev/null \
"**/*.adoc" \
2>&1 | \
grep \
-v \
"include file not found" \
)
result=$?
# Fail the action if there was an unexpected error code, or any output from the build
if [[ ${result} != 0 ]]; then
exit ${result}
elif [[ ${output} ]]; then
while IFS= read -r line; do
if [[ "${line}" == *"ERROR"* ]]; then
severity=error
elif [[ "${line}" == *"WARNING"* ]]; then
severity=warning
else
severity=notice
fi
echo "::${severity}::${line}"
done <<< "${output}"
exit 1
fi
12 changes: 12 additions & 0 deletions .github/workflows/test-adoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test asciidoctor files

on:
pull_request:

jobs:
test-adoc:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test-adoc

0 comments on commit d9bccb9

Please sign in to comment.