diff options
| author | jyn <github@jyn.dev> | 2023-03-26 10:28:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-27 00:28:07 +0900 |
| commit | 56c1d301b492440d5d40ce21fef6a60ca73a23be (patch) | |
| tree | a5e4d73b8d7c27ca84e3920dd824909ffe68c47c /src/doc/rustc-dev-guide/ci | |
| parent | 52dd6d812a077624d20faed8ba7674c52f8a375e (diff) | |
Don't require $GITHUB_TOKEN to build locally (#1652)
Diffstat (limited to 'src/doc/rustc-dev-guide/ci')
| -rwxr-xr-x | src/doc/rustc-dev-guide/ci/linkcheck.sh | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/doc/rustc-dev-guide/ci/linkcheck.sh b/src/doc/rustc-dev-guide/ci/linkcheck.sh index 5d49d133726..133e2223970 100755 --- a/src/doc/rustc-dev-guide/ci/linkcheck.sh +++ b/src/doc/rustc-dev-guide/ci/linkcheck.sh @@ -3,12 +3,16 @@ set -e 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 if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job FLAGS="" + USE_TOKEN=1 echo "Doing full link check." - set -x elif [ "$GITHUB_EVENT_NAME" = "pull_request" ] ; then # running in PR CI build if [ -z "$BASE_SHA" ]; then 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' ' ') FLAGS="--no-cache -f $CHANGED_FILES" + USE_TOKEN=1 echo "Checking files changed since $BASE_SHA: $CHANGED_FILES" - set -x else # running locally COMMIT_RANGE=master... 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" fi -exec mdbook-linkcheck $FLAGS +echo "exec mdbook-linkcheck $FLAGS" +if [ "$USE_TOKEN" = 1 ]; then + config=$(set_github_token) + exec mdbook-linkcheck $FLAGS <<<"$config" +else + exec mdbook-linkcheck $FLAGS +fi |
