mirror of
https://github.com/orhun/git-cliff-action.git
synced 2026-05-06 21:02:01 +08:00
feat(env): improve GitHub Token handling (#77)
* fix: stop `env.GITHUB_TOKEN` from overriding `github_token` input Previously, `GITHUB_API_TOKEN` and `GITHUB_TOKEN` were resolved as `env.GITHUB_TOKEN || inputs.github_token`, meaning the environment variable took priority over the action input. On Forgejo/Gitea runners, `GITHUB_TOKEN` is automatically set to a non-GitHub token, which silently overrode any user-provided github_token input and caused GitHub API calls to fail. * Improve GitHub API token input handling Updated GitHub API token handling to use fallback values. * Clarify 'github_token' description in README Reworded the description of the 'github_token' parameter for clarity. * Fix formatting of GitHub token description in README * Update README with GitHub API token precedence Added note on GitHub API token precedence in README. * Update README.md --------- Co-authored-by: Maxim Slipenko <maxim@slipenko.com> Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
This commit is contained in:
@@ -9,7 +9,14 @@ This action generates a changelog based on your Git history using [git-cliff](ht
|
|||||||
- `version`: `git-cliff` version to use. (e.g. `"latest"`, `"v2.12.0"`)
|
- `version`: `git-cliff` version to use. (e.g. `"latest"`, `"v2.12.0"`)
|
||||||
- `config`: Path of the configuration file. (Default: `"cliff.toml"`)
|
- `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"`)
|
- `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 }}`)
|
- `github_token`: The GitHub API token used to download `git-cliff` and to authenticate git-cliff's [GitHub integration](https://git-cliff.org/docs/integration/github) (e.g. extracting usernames, contributors, PR links) to avoid rate limits. Requires a classic or fine-grained token without permissions.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> GitHub API token order of precedence is as follows:
|
||||||
|
>
|
||||||
|
> 1. Input variable (`github_token`)
|
||||||
|
> 2. Environment variable (`GITHUB_TOKEN`)
|
||||||
|
> 3. GitHub context (default) (`${{ github.token }}`)
|
||||||
|
|
||||||
### Output variables
|
### Output variables
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -16,7 +16,6 @@ inputs:
|
|||||||
github_token:
|
github_token:
|
||||||
description: "GitHub API token"
|
description: "GitHub API token"
|
||||||
required: false
|
required: false
|
||||||
default: "${{ github.token }}"
|
|
||||||
outputs:
|
outputs:
|
||||||
changelog:
|
changelog:
|
||||||
description: "output file"
|
description: "output file"
|
||||||
@@ -37,14 +36,14 @@ runs:
|
|||||||
RUNNER_OS: ${{ runner.os }}
|
RUNNER_OS: ${{ runner.os }}
|
||||||
RUNNER_ARCH: ${{ runner.arch }}
|
RUNNER_ARCH: ${{ runner.arch }}
|
||||||
VERSION: ${{ inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
GITHUB_API_TOKEN: ${{ env.GITHUB_TOKEN || inputs.github_token }}
|
GITHUB_API_TOKEN: ${{ inputs.github_token || env.GITHUB_TOKEN || github.token }}
|
||||||
|
|
||||||
- name: Run git-cliff
|
- name: Run git-cliff
|
||||||
id: run-git-cliff
|
id: run-git-cliff
|
||||||
shell: bash
|
shell: bash
|
||||||
run: ${GITHUB_ACTION_PATH}/run.sh --config=${{ inputs.config }} ${{ inputs.args }}
|
run: ${GITHUB_ACTION_PATH}/run.sh --config=${{ inputs.config }} ${{ inputs.args }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN || inputs.github_token }}
|
GITHUB_TOKEN: ${{ inputs.github_token || env.GITHUB_TOKEN || github.token }}
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: "triangle"
|
icon: "triangle"
|
||||||
|
|||||||
Reference in New Issue
Block a user