Skip to content

Commit

Permalink
Rearrange actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Johennes committed Aug 8, 2024
1 parent d50a2c6 commit a37d278
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 61 deletions.
60 changes: 0 additions & 60 deletions .github/actions/lint-jsonschema/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,63 +50,3 @@ runs:
done < <(find "$EXAMPLES_ROOT" -name "*.json")
exit $rc
- name: Verify links
shell: bash
run: |
function warn {
>&2 echo -e "\033[0;33m$@\033[0m"
}
function err {
>&2 echo -e "\033[0;31m$@\033[0m"
}
rc=0
while read -r file; do
echo "Checking $file"
pushd "$(dirname "$file")" > /dev/null
while read -r location; do
echo "Checking location $location"
if [[ "$location" == http* ]]; then
if ! curl -X OPTIONS --silent --fail "$location" 2>&1 > /dev/null; then
if ! curl --head --silent --fail "$location" 2>&1 > /dev/null; then
if ! curl --silent --fail "$location" 2>&1 > /dev/null; then
# Some URLs are examples or the endpoints helpfully support neither OPTIONS nor HEAD
if [[ "$location" = *example* ]] || \
[[ "$location" = https://idp-ref.app.ti-dienste.de/auth* ]] || \
[[ "$location" = https://idp.app.ti-dienste.de/auth* ]] || \
[[ "$location" = https://idp-ref.app.ti-dienste.de/token* ]] || \
[[ "$location" = https://idp.app.ti-dienste.de/token* ]] || \
[[ "$location" = https://idp-ref.app.ti-dienste.de ]];
then
warn "$file references non-verifiable location $location"
else
err "$file references non-existent location $location"
rc=1
fi
fi
fi
fi
else
# Strip fragments and prefix absolute paths with repo root
path=${location/\#*/}
if [[ "$path" == /* ]]; then
path=$(git rev-parse --show-toplevel)/$path
fi
if [[ ! -e "$path" ]]; then
err "$file references non-existent location $location"
rc=1
fi
fi
done < <(grep -hoE 'link:[^\[]*|image::?[^\[]*|https?://[^\["[:space:]]*' "$(basename "$file")" | grep -v '^image:' | sed -E "s/^link:+//g")
popd > /dev/null
done < <(find . -type f -name "*.adoc")
exit $rc
64 changes: 64 additions & 0 deletions .github/actions/lint-links/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Lint Links

runs:
using: "composite"
steps:
- name: Verify links
shell: bash
run: |
function warn {
>&2 echo -e "\033[0;33m$@\033[0m"
}
function err {
>&2 echo -e "\033[0;31m$@\033[0m"
}
rc=0
while read -r file; do
echo "Checking $file"
pushd "$(dirname "$file")" > /dev/null
while read -r location; do
echo "Checking location $location"
if [[ "$location" == http* ]]; then
if ! curl -X OPTIONS --silent --fail "$location" 2>&1 > /dev/null; then
if ! curl --head --silent --fail "$location" 2>&1 > /dev/null; then
if ! curl --silent --fail "$location" 2>&1 > /dev/null; then
# Some URLs are examples or the endpoints helpfully support neither OPTIONS nor HEAD
if [[ "$location" = *example* ]] || \
[[ "$location" = https://idp-ref.app.ti-dienste.de/auth* ]] || \
[[ "$location" = https://idp.app.ti-dienste.de/auth* ]] || \
[[ "$location" = https://idp-ref.app.ti-dienste.de/token* ]] || \
[[ "$location" = https://idp.app.ti-dienste.de/token* ]] || \
[[ "$location" = https://idp-ref.app.ti-dienste.de ]];
then
warn "$file references non-verifiable location $location"
else
err "$file references non-existent location $location"
rc=1
fi
fi
fi
fi
else
# Strip fragments and prefix absolute paths with repo root
path=${location/\#*/}
if [[ "$path" == /* ]]; then
path=$(git rev-parse --show-toplevel)/$path
fi
if [[ ! -e "$path" ]]; then
err "$file references non-existent location $location"
rc=1
fi
fi
done < <(grep -hoE 'link:[^\[]*|image::?[^\[]*|https?://[^\["[:space:]]*' "$(basename "$file")" | grep -v '^image:' | sed -E "s/^link:+//g")
popd > /dev/null
done < <(find . -type f -name "*.adoc")
exit $rc
12 changes: 11 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:

jobs:
asciidoc:
asciidoc-images:
runs-on: ubuntu-latest

steps:
Expand All @@ -19,6 +19,16 @@ jobs:
- name: Lint
uses: gematik/github-image-actions/.github/actions/[email protected]

asciidoc-links:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint
uses: ./.github/actions/lint-links

drawio:
runs-on: ubuntu-latest

Expand Down

0 comments on commit a37d278

Please sign in to comment.