Skip to content

Commit b4e778a

Browse files
authored
Don't require $GITHUB_TOKEN to build locally (rust-lang#1652)
1 parent 5eca473 commit b4e778a

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ To build a local static HTML site, install [`mdbook`](https://github.com/rust-la
4949
and execute the following command in the root of the repository:
5050

5151
```
52-
> mdbook build
52+
> mdbook build --open
5353
```
5454

55-
The build files are found in the `book` directory.
55+
The build files are found in the `book/html` directory.
5656

5757
### Link Validations
5858

book.toml

-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ exclude = [
4343
cache-timeout = 86400
4444
warning-policy = "error"
4545

46-
[output.linkcheck.http-headers]
47-
'github\.com' = ["Authorization: Bearer $GITHUB_TOKEN"]
48-
4946
[output.html.redirect]
5047
"/compiletest.html" = "tests/compiletest.html"
5148
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"

ci/linkcheck.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
set -e
44
set -o pipefail
55

6+
set_github_token() {
7+
jq '.config.output.linkcheck."http-headers"."github\\.com" = ["Authorization: Bearer $GITHUB_TOKEN"]'
8+
}
9+
610
# https://docs.github.com/en/actions/reference/environment-variables
711
if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job
812
FLAGS=""
13+
USE_TOKEN=1
914

1015
echo "Doing full link check."
11-
set -x
1216
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build
1317
if [ -z "$BASE_SHA" ]; then
1418
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
1721

1822
CHANGED_FILES=$(git diff --name-only $BASE_SHA... | tr '\n' ' ')
1923
FLAGS="--no-cache -f $CHANGED_FILES"
24+
USE_TOKEN=1
2025

2126
echo "Checking files changed since $BASE_SHA: $CHANGED_FILES"
22-
set -x
2327
else # running locally
2428
COMMIT_RANGE=master...
2529
CHANGED_FILES=$(git diff --name-only $COMMIT_RANGE | tr '\n' ' ')
@@ -28,4 +32,10 @@ else # running locally
2832
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
2933
fi
3034

31-
exec mdbook-linkcheck $FLAGS
35+
echo "exec mdbook-linkcheck $FLAGS"
36+
if [ "$USE_TOKEN" = 1 ]; then
37+
config=$(set_github_token)
38+
exec mdbook-linkcheck $FLAGS <<<"$config"
39+
else
40+
exec mdbook-linkcheck $FLAGS
41+
fi

0 commit comments

Comments
 (0)