This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-website.git
commit 7723118e34966f10da27fa6770db7d501a0e22d7 Author: Zoran Regvart <zo...@regvart.com> AuthorDate: Mon Mar 21 11:06:02 2022 +0100 feat: use `GITHUB_TOKEN` for API authentication This makes use of the `GITHUB_TOKEN` environment variable, if defined, to authenticate the API requests. Since the `GITHUB_TOKEN` is provided to the GitHub workflow automatically[1], this should help with rate limits when building the website. [1] https://docs.github.com/en/actions/security-guides/automatic-token-authentication --- .github/workflows/pr.yaml | 2 ++ README.md | 8 ++++++-- config.toml | 2 +- layouts/blog/post.html | 8 +++++++- layouts/blog/summary.html | 8 +++++++- layouts/partials/releases/camel-k-runtime.html | 8 +++++++- layouts/partials/releases/camel-k.html | 8 +++++++- layouts/partials/releases/camel-kafka-connector.html | 8 +++++++- layouts/partials/releases/camel-quarkus.html | 8 +++++++- 9 files changed, 51 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d432c83..e0a5ccb 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -32,6 +32,8 @@ jobs: - name: Check cache run: yarn check:dependencies - name: Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: yarn build-all - name: Run checks run: yarn checks diff --git a/README.md b/README.md index b65af95..28b59ff2 100644 --- a/README.md +++ b/README.md @@ -115,11 +115,15 @@ project directory on your filesystem. ## Build the website and Antora theme Some of the content for the website is derived from the data received from GitHub API and rate limits can cause -build failures. For that reason it is necessary to set the following environment variables: +build failures. For that reason it is necessary to set either the following environment variables: - `HUGO_PARAMS_GitHubUsername=<GitHub username>` - `HUGO_PARAMS_GitHubToken=<GitHub token>` +Or the following environment variable: + + - `GITHUB_TOKEN=<personal access token>` + These values are used by Hugo when building or running in development mode (`yarn preview:hugo`) or building the website (`yarn build:hugo` or `yarn build-all`) to access GitHub API with a higher rate limit. @@ -352,7 +356,7 @@ Other components are in the obvious repository. - To link to another page in the same component/version/module use the absolute path from "pages": xref:path/to/page.adoc[]. For instance, a link from one camel component to another would be xref:activemq-component.adoc[]. - A link from any camel-quarkus page to a camel-quarkus extension would be xref:reference/extensions/activemq.adoc[]. + A link from any camel-quarkus page to a camel-quarkus extension would be xref:reference/extensions/activemq.adoc[]. - To link to a page in another module in the same component/version use the module name and absolute path from "pages": xref:module:path/to/page.adoc[]. For instance, a link from a dataformat to a language would be xref:languages:jsonpath-language.adoc[]. A link from a dataformat to an eip would be xref:eips:aggregate-eip.adoc[]. diff --git a/config.toml b/config.toml index 4d97f24..febe47b 100644 --- a/config.toml +++ b/config.toml @@ -22,7 +22,7 @@ defaultMarkdownHandler = "blackfriday" GitHubToken = "" [security.funcs] - getenv = ['^HUGO_','CAMEL_ENV'] + getenv = ['^HUGO_','CAMEL_ENV', 'GITHUB_TOKEN'] [caches] diff --git a/layouts/blog/post.html b/layouts/blog/post.html index 87e615b..10a016e 100644 --- a/layouts/blog/post.html +++ b/layouts/blog/post.html @@ -13,7 +13,13 @@ Posted on <time itemprop="published" datetime="{{ dateFormat "2006-01-02" .PublishDate }}" title="{{ dateFormat "Monday, January 2, 2006" .PublishDate }}">{{ dateFormat "January 2, 2006" .PublishDate }}</time>, by {{ range $author := .Params.authors }} - {{ with getJSON "https://api.github.com/users/" $author (dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode))) }} + {{ $headers := dict }} + {{ with os.Getenv "GITHUB_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} + {{ else }} + {{ $headers = dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)) }} + {{ end }} + {{ with getJSON "https://api.github.com/users/" $author $headers }} <figure> <img src="{{ .avatar_url }}" alt="{{ .name }}"> <figcaption rel="author">{{ .name }}</figcaption> diff --git a/layouts/blog/summary.html b/layouts/blog/summary.html index b260ffc..eeae4b9 100644 --- a/layouts/blog/summary.html +++ b/layouts/blog/summary.html @@ -2,7 +2,13 @@ <header> <a href="{{ .RelPermalink }}"><h1>{{ .Title }}</h1></a> - <time itemprop="published" datetime="{{ dateFormat "2006-01-02" .PublishDate }}" title="{{ dateFormat "Monday, January 2, 2006" .PublishDate }}">{{ dateFormat "January 2, 2006" .PublishDate }}</time>, by {{ range $idx, $author := .Params.authors }}{{ if gt $idx 0 }}, {{ end }}<span rel="author">{{ (getJSON "https://api.github.com/users/" $author (dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)))).name [...] + {{ $headers := dict }} + {{ with os.Getenv "GITHUB_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} + {{ else }} + {{ $headers = dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)) }} + {{ end }} + <time itemprop="published" datetime="{{ dateFormat "2006-01-02" .PublishDate }}" title="{{ dateFormat "Monday, January 2, 2006" .PublishDate }}">{{ dateFormat "January 2, 2006" .PublishDate }}</time>, by {{ range $idx, $author := .Params.authors }}{{ if gt $idx 0 }}, {{ end }}<span rel="author">{{ (getJSON "https://api.github.com/users/" $author $headers).name }}</span>{{ end }} </header> <p>{{ .Summary }}</p> <p><a class="continue" href="{{ .RelPermalink }}">Continue reading ❯</a></p> diff --git a/layouts/partials/releases/camel-k-runtime.html b/layouts/partials/releases/camel-k-runtime.html index 379e880..4221553 100644 --- a/layouts/partials/releases/camel-k-runtime.html +++ b/layouts/partials/releases/camel-k-runtime.html @@ -11,7 +11,13 @@ git checkout camel-k-runtime-parent-{{ .Params.version }}</pre> <h2 id="resolved"><a class="anchor" href="#resolved"></a>Resolved issues</h2> <p>Here is a list of all the issues that have been resolved for this release</p> -{{ $issues := getJSON "https://api.github.com/repos/apache/camel-k-runtime/issues?state=closed&milestone=" (string .Params.milestone ) (dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode))) }} +{{ $headers := dict }} +{{ with os.Getenv "GITHUB_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} +{{ else }} + {{ $headers = dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)) }} +{{ end }} +{{ $issues := getJSON "https://api.github.com/repos/apache/camel-k-runtime/issues?state=closed&milestone=" (string .Params.milestone ) $headers }} <dl> {{ range $issues }} <dt><a href="{{ .html_url }}">#{{ .number }}</a></dt><dd>{{ .title }}</dd> diff --git a/layouts/partials/releases/camel-k.html b/layouts/partials/releases/camel-k.html index 7478c5c..61da4a3 100644 --- a/layouts/partials/releases/camel-k.html +++ b/layouts/partials/releases/camel-k.html @@ -11,7 +11,13 @@ git checkout v{{ .Params.version }}</pre> <h2 id="resolved"><a class="anchor" href="#resolved"></a>Resolved issues</h2> <p>Here is a list of all the issues that have been resolved for this release</p> -{{ $issues := getJSON "https://api.github.com/repos/apache/camel-k/issues?state=closed&milestone=" (string .Params.milestone) (dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode))) }} +{{ $headers := dict }} +{{ with os.Getenv "GITHUB_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} +{{ else }} + {{ $headers = dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)) }} +{{ end }} +{{ $issues := getJSON "https://api.github.com/repos/apache/camel-k/issues?state=closed&milestone=" (string .Params.milestone) $headers }} <dl> {{ range $issues }} <dt><a href="{{ .html_url }}">#{{ .number }}</a></dt><dd>{{ .title }}</dd> diff --git a/layouts/partials/releases/camel-kafka-connector.html b/layouts/partials/releases/camel-kafka-connector.html index acad116..1f3d951 100644 --- a/layouts/partials/releases/camel-kafka-connector.html +++ b/layouts/partials/releases/camel-kafka-connector.html @@ -26,7 +26,13 @@ git checkout camel-kafka-connector-{{ .Params.version }}</pre> <h2 id="resolved"><a class="anchor" href="#resolved"></a>Resolved issues</h2> <p>Here is a list of all the issues that have been resolved for this release</p> -{{ $issues := getJSON "https://api.github.com/repos/apache/camel-kafka-connector/issues?state=closed&labels=" (string .Params.version) (dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode))) }} +{{ $headers := dict }} +{{ with os.Getenv "GITHUB_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} +{{ else }} + {{ $headers = dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)) }} +{{ end }} +{{ $issues := getJSON "https://api.github.com/repos/apache/camel-kafka-connector/issues?state=closed&labels=" (string .Params.version) $headers }} <dl> {{ range $issues }} <dt><a href="{{ .html_url }}">#{{ .number }}</a></dt><dd>{{ .title }}</dd> diff --git a/layouts/partials/releases/camel-quarkus.html b/layouts/partials/releases/camel-quarkus.html index 77c175c..074b887 100644 --- a/layouts/partials/releases/camel-quarkus.html +++ b/layouts/partials/releases/camel-quarkus.html @@ -11,7 +11,13 @@ git checkout {{ .Params.version }}</pre> <h2 id="resolved"><a class="anchor" href="#resolved"></a>Resolved issues</h2> <p>Here is a list of all the issues that have been resolved for this release</p> -{{ $issues := getJSON "https://api.github.com/repos/apache/camel-quarkus/issues?state=closed&milestone=" (string .Params.milestone) (dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode))) }} +{{ $headers := dict }} +{{ with os.Getenv "GITHUB_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} +{{ else }} + {{ $headers = dict "Authorization" (printf "Basic %s" (printf "%s:%s" $.Site.Params.GitHubUsername $.Site.Params.GitHubToken | base64Encode)) }} +{{ end }} +{{ $issues := getJSON "https://api.github.com/repos/apache/camel-quarkus/issues?state=closed&milestone=" (string .Params.milestone) $headers }} <dl> {{ range $issues }} <dt><a href="{{ .html_url }}">#{{ .number }}</a></dt><dd>{{ .title }}</dd>