Don't require $GITHUB_TOKEN to build locally (#1652)
This commit is contained in:
parent
266ca693c0
commit
b4b007be06
|
|
@ -49,10 +49,10 @@ To build a local static HTML site, install [`mdbook`](https://github.com/rust-la
|
||||||
and execute the following command in the root of the repository:
|
and execute the following command in the root of the repository:
|
||||||
|
|
||||||
```
|
```
|
||||||
> mdbook build
|
> mdbook build --open
|
||||||
```
|
```
|
||||||
|
|
||||||
The build files are found in the `book` directory.
|
The build files are found in the `book/html` directory.
|
||||||
|
|
||||||
### Link Validations
|
### Link Validations
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@ exclude = [
|
||||||
cache-timeout = 86400
|
cache-timeout = 86400
|
||||||
warning-policy = "error"
|
warning-policy = "error"
|
||||||
|
|
||||||
[output.linkcheck.http-headers]
|
|
||||||
'github\.com' = ["Authorization: Bearer $GITHUB_TOKEN"]
|
|
||||||
|
|
||||||
[output.html.redirect]
|
[output.html.redirect]
|
||||||
"/compiletest.html" = "tests/compiletest.html"
|
"/compiletest.html" = "tests/compiletest.html"
|
||||||
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
|
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,16 @@
|
||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
set_github_token() {
|
||||||
|
jq '.config.output.linkcheck."http-headers"."github\\.com" = ["Authorization: Bearer $GITHUB_TOKEN"]'
|
||||||
|
}
|
||||||
|
|
||||||
# https://docs.github.com/en/actions/reference/environment-variables
|
# https://docs.github.com/en/actions/reference/environment-variables
|
||||||
if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job
|
if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job
|
||||||
FLAGS=""
|
FLAGS=""
|
||||||
|
USE_TOKEN=1
|
||||||
|
|
||||||
echo "Doing full link check."
|
echo "Doing full link check."
|
||||||
set -x
|
|
||||||
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build
|
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build
|
||||||
if [ -z "$BASE_SHA" ]; then
|
if [ -z "$BASE_SHA" ]; then
|
||||||
echo "error: unexpected state: BASE_SHA must be non-empty in CI"
|
echo "error: unexpected state: BASE_SHA must be non-empty in CI"
|
||||||
|
|
@ -17,9 +21,9 @@ elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build
|
||||||
|
|
||||||
CHANGED_FILES=$(git diff --name-only $BASE_SHA... | tr '\n' ' ')
|
CHANGED_FILES=$(git diff --name-only $BASE_SHA... | tr '\n' ' ')
|
||||||
FLAGS="--no-cache -f $CHANGED_FILES"
|
FLAGS="--no-cache -f $CHANGED_FILES"
|
||||||
|
USE_TOKEN=1
|
||||||
|
|
||||||
echo "Checking files changed since $BASE_SHA: $CHANGED_FILES"
|
echo "Checking files changed since $BASE_SHA: $CHANGED_FILES"
|
||||||
set -x
|
|
||||||
else # running locally
|
else # running locally
|
||||||
COMMIT_RANGE=master...
|
COMMIT_RANGE=master...
|
||||||
CHANGED_FILES=$(git diff --name-only $COMMIT_RANGE | tr '\n' ' ')
|
CHANGED_FILES=$(git diff --name-only $COMMIT_RANGE | tr '\n' ' ')
|
||||||
|
|
@ -28,4 +32,10 @@ else # running locally
|
||||||
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
|
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "exec mdbook-linkcheck $FLAGS"
|
||||||
|
if [ "$USE_TOKEN" = 1 ]; then
|
||||||
|
config=$(set_github_token)
|
||||||
|
exec mdbook-linkcheck $FLAGS <<<"$config"
|
||||||
|
else
|
||||||
exec mdbook-linkcheck $FLAGS
|
exec mdbook-linkcheck $FLAGS
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue