-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ on: | |
workflow_dispatch: | ||
|
||
jobs: | ||
asciidoc: | ||
asciidoc-images: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -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 | ||
|
||
|