Skip to content

Commit

Permalink
fix 'github-actions[bot]' usage
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Nov 28, 2023
1 parent 365f527 commit 8883a56
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Here are the configuration options for this Action:
| Input | Required? | Default | Description |
|-----------| --------- |---------------------------------------------| ----------- |
| `github_token` | yes | `${{ github.token }}` | The GitHub token used to create an authenticated client - Provided for you by default! - You can use the default provided token or you can provide a PAT as an alternative robot user token. Make sure this is a repository scoped token |
| `handle` | yes | `github-actions[bot]` | When using the default `${{ github.token }}` (as seen above), the "handle" is fetched from this input since the token is repository scoped and it cannot even read its own handle. You should not need to change this input. |
| `path` | yes | `config/privileged-requester.yaml` | Path where the privileged requester configuration can be found |
| `prCreator` | yes | `${{ github.event.pull_request.user.login }}` | The creator of the PR for this pull request event |
| `prNumber` | yes | `${{ github.event.pull_request.number }}` | The number of the PR for this pull request event |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
You can use the default provided token or you can provide a PAT as an alternative robot user token
required: true
default: ${{ github.token }}
handle:
description: 'When using the default ${{ github.token }}, the "handle" is fetched from this input since the token is repository scoped and it cannot even read its own handle. You should not need to change this input.'
required: true
default: github-actions[bot]
path:
description: 'Path where the privileged requester configuration can be found'
required: true
Expand Down
9 changes: 4 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/github-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ class GitHubProvider {
} catch (error) {
core.debug(error);
core.debug(
`octokit.rest.users.getAuthenticated() failed, trying with octokit.rest.apps.getAuthenticated() instead`,
`octokit.rest.users.getAuthenticated() failed, assuming the default input GITHUB_TOKEN is a github-actions[bot] token`,
);
const { data: currentApp } =
await this.octokit.rest.apps.getAuthenticated();
login = currentApp.slug;
core.debug(
"obtained current user via octokit.rest.apps.getAuthenticated()",
`since the GITHUB_TOKEN might be 'github-actions[bot]' we will use the default input option of 'handle' instead`,
);
login = core.getInput("handle", { required: true });
core.debug(`handle value: ${login}`);
}

core.debug(`current user: ${login}`);
Expand Down

0 comments on commit 8883a56

Please sign in to comment.