Skip to content

Rework image generation workflow #18

Rework image generation workflow

Rework image generation workflow #18

Workflow file for this run

name: Lint
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
drawio:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Verify number of diagrams
run: |
function err {
>&2 echo -e "\033[0;31m$@\033[0m"
}
rc=0
while read -r file; do
echo "Checking $file"
if [[ $(grep "<diag" "$file" | wc -l) -ne 1 ]]; then
err "$file does not contain exactly one diagram"
rc=1
fi
done < <(find . -name "*.drawio")
exit $rc
asciidoc:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Verify image references
run: |
function err {
>&2 echo -e "\033[0;31m$@\033[0m"
}
rc=0
while read -r file; do
echo "Checking $file"
root=$(grep "^:imagesdir:" "$file" | sed -E "s/^:imagesdir:[[:space:]]*//")
if [[ ! -z "$root" ]]; then
if [[ "$root" == /* ]]; then
root=$(git rev-parse --show-toplevel)$root
fi
if [[ ! "$root" == */ ]]; then
root=$root/
fi
fi
echo "Found imagedir ${root:-<null>}"
pushd "$(dirname "$file")" > /dev/null
while read -r location; do
echo "Checking location $location"
if [[ "$location" == http* ]]; then
if ! curl --head --silent --fail "$location" 2>&1 > /dev/null; then
err "$file references non-existent image $location"
rc=1
fi
else
if [[ ! -f "$root$location" ]]; then
err "$file references non-existent image $location with imagedir ${root:-<null>}"
rc=1
fi
fi
done < <(grep -oE "image:+[^\[]*" "$(basename "$file")" | sed -E "s/^image:+//g")
popd > /dev/null
done < <(find . -type f -name "*.adoc")
exit $rc