Skip to content

Commit

Permalink
fix: use a dedicated input variable to pass github token
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Ortega <[email protected]>
  • Loading branch information
M0NsTeRRR committed Sep 16, 2024
1 parent 9f1a664 commit 247ff27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This action generates a changelog based on your Git history using [git-cliff](ht
- `version`: `git-cliff` version to use. (e.g. `"latest"`, `"v2.5.0"`)
- `config`: Path of the configuration file. (Default: `"cliff.toml"`)
- `args`: [Arguments](https://github.com/orhun/git-cliff#usage) to pass to git-cliff. (Default: `"-v"`)
- `github_token`: The GitHub API token used to get git-cliff release information via the GitHub API to avoid rate limits. (Default: `${{ github.token }}`)

### Output variables

Expand All @@ -32,6 +33,13 @@ This action generates a changelog based on your Git history using [git-cliff](ht
>
> Otherwise, you might end up getting empty changelogs or `git ref` errors depending on arguments passed to `git-cliff`.
### Running the action outside of GitHub
If you run the action in Gitea or GitHub Enterprise, the `github_token` input is invalid. You have two options:
- Pass an empty value `github_token: ""` (limit of 60 requests per hour per IP address).
- Create a GitHub token and pass it through GitHub secrets to avoid rate limiting.
### Examples
#### Simple
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: "git-cliff arguments"
required: false
default: "-v"
github_token:
description: "GitHub API token"
required: false
default: "${{ github.token }}"
outputs:
changelog:
description: "output file"
Expand All @@ -33,7 +37,7 @@ runs:
RUNNER_OS: ${{ runner.os }}
RUNNER_ARCH: ${{ runner.arch }}
VERSION: ${{ inputs.version }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_API_TOKEN: ${{ inputs.version }}

- name: Run git-cliff
id: run-git-cliff
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [[ "${VERSION}" != 'latest' ]]; then
fi

# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
if [[ -z "${GITHUB_TOKEN}" ]]; then
if [[ -z "${GITHUB_API_TOKEN}" ]]; then
RELEASE_INFO="$(curl --silent --show-error --fail \
--header 'Cache-Control: no-cache, must-revalidate' \
"${RELEASE_URL}")"
Expand All @@ -29,7 +29,7 @@ else
# in order to increase the limit of 60 requests per hour per IP address to a higher value that's also counted
# per GitHub account.
RELEASE_INFO="$(curl --silent --show-error --fail \
--header "authorization: Bearer ${GITHUB_TOKEN}" \
--header "authorization: Bearer ${GITHUB_API_TOKEN}" \
--header 'Cache-Control: no-cache, must-revalidate' \
"${RELEASE_URL}")"
fi
Expand Down

0 comments on commit 247ff27

Please sign in to comment.