Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin committed Dec 29, 2024
1 parent f5e11cd commit 7c88005
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ci/linkcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
set -e
set -o pipefail

LINKCHECK_BINARY=mdbook-linkcheck2

set_github_token() {
jq '.config.output.linkcheck."http-headers"."github\\.com" = ["Authorization: Bearer $GITHUB_TOKEN"]'
}

if [ ! -z "$SKIP_LINKCHECK" ] ; then
echo "Skipping link check."
exec mdbook-linkcheck -f ""
exec $LINKCHECK_BINARY -f ""
fi

# https://docs.github.com/en/actions/reference/environment-variables
Expand Down Expand Up @@ -37,10 +39,10 @@ else # running locally
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
fi

echo "exec mdbook-linkcheck2 $FLAGS"
echo "exec $LINKCHECK_BINARY $FLAGS"
if [ "$USE_TOKEN" = 1 ]; then
config=$(set_github_token)
exec mdbook-linkcheck2 $FLAGS <<<"$config"
exec $LINKCHECK_BINARY $FLAGS <<<"$config"
else
exec mdbook-linkcheck2 $FLAGS
exec $LINKCHECK_BINARY $FLAGS
fi

0 comments on commit 7c88005

Please sign in to comment.