add github token to local docker build (#5073)

Signed-off-by: Paul S. Schweigert <paulschw@us.ibm.com>
This commit is contained in:
Paul Schweigert 2022-07-12 11:17:13 -04:00 committed by GitHub
parent 4ddc8f9c4d
commit 97bcb7b276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -37,6 +37,8 @@ The build output is the entire static site located in `./site`.
You can preview the website locally by running a webserver using this directory like `npx http-server site -p 8000` if you have Node.js or `python3 -m http.server 8000` if you have Python 3. You can preview the website locally by running a webserver using this directory like `npx http-server site -p 8000` if you have Node.js or `python3 -m http.server 8000` if you have Python 3.
To run this script, you will need to set the `GITHUB_TOKEN` environmental variable to your [Github Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
## (Option 2) Using native Python mkdocs CLI ## (Option 2) Using native Python mkdocs CLI

View File

@ -1,9 +1,14 @@
#!/usr/bin/env sh #!/usr/bin/env sh
if [ -z $GITHUB_TOKEN ]; then
echo "Please set a value for the GITHUB_TOKEN environmental variable"
exit 1
fi
SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P) SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P)
IMAGE=${1:-ghcr.io/knative/knative-docs:latest} IMAGE=${1:-ghcr.io/knative/knative-docs:latest}
set -x set -x
docker pull ${IMAGE} docker pull ${IMAGE}
docker run --rm -v "${SCRIPT_DIR}/../../:/site" -it --entrypoint "" ${IMAGE} hack/build.sh docker run --rm -v "${SCRIPT_DIR}/../../:/site" -e GITHUB_TOKEN -it --entrypoint "" ${IMAGE} hack/build.sh