use one token and one token only

This commit is contained in:
GrantBirki 2023-11-27 12:44:55 -07:00
Родитель 1029a708ae
Коммит ba3763e25e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9029BBCCC15C6F8C
6 изменённых файлов: 14 добавлений и 35 удалений

3
.github/workflows/privileged-requester.yml поставляемый
Просмотреть файл

@ -16,8 +16,7 @@ jobs:
- uses: ./
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
robotUserToken: ${{ secrets.REPO_GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
path: config/privileged-requester.yaml
prCreator: ${{ github.event.pull_request.user.login }}
prNumber: ${{ github.event.pull_request.number }}

Просмотреть файл

@ -29,8 +29,7 @@ jobs:
- uses: github/privileged-requester@vX.X.X
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
robotUserToken: ${{ secrets.REPO_GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
path: config/privileged-requester.yaml
prCreator: ${{ github.event.pull_request.user.login }}
prNumber: ${{ github.event.pull_request.number }}
@ -62,7 +61,7 @@ The location of this file in the target repo should be the path used in the work
This Action runs, by default, with the built-in `GITHUB_TOKEN` and so approves the PRs as the `github-actions[bot]` user.
However, you can configure the Action to run with a different repo scoped token - a bot user of your own - by defining the Workflow configuration option `robotUserToken` pointing to the repo secret for that token.
However, you can configure the Action to run with a different repo scoped token - a bot user of your own - by defining the Workflow configuration option `github_token` pointing to the repo secret for that token.
## Configuration
@ -72,8 +71,7 @@ Here are the configuration options for this Action:
| Input | Required? | Default | Description |
|-----------| --------- |---------------------------------------------| ----------- |
| `myToken` | yes | `${{ github.token }}` | The GitHub token used to create an authenticated client - Provided for you by default! |
| robotUserToken | no | - | An alternative robot user PAT to be used instead of the built-in Actions token |
| `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 |
| `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 |

Просмотреть файл

@ -4,13 +4,13 @@ branding:
icon: 'check'
color: 'green'
inputs:
myToken:
description: 'Repository scoped token'
github_token:
description: |
'The GitHub token used to create an authenticated client - Provided for you by default! - Repository scoped token'
You can use the default provided token or you can provide a PAT as an alternative robot user token
required: true
default: ${{ github.token }}
robotUserToken:
description: 'An alternative robot user PAT to be used instead of the built-in Actions token'
required: false
path:
description: 'Path where the privileged requester configuration can be found'
required: true

13
dist/index.js сгенерированный поставляемый
Просмотреть файл

@ -37318,17 +37318,8 @@ class Runner {
const index_core = __nccwpck_require__(2186);
let myToken = index_core.getInput("myToken");
const robotUserToken = index_core.getInput("robotUserToken");
if (
robotUserToken !== "" ||
robotUserToken !== undefined ||
robotUserToken !== null
) {
index_core.info("Robot User configured. I will use that PAT instead.");
myToken = robotUserToken;
}
const provider = new GitHubProvider(myToken);
const token = index_core.getInput("github_token", { required: true });
const provider = new GitHubProvider(token);
const pullRequest = new PullRequest(provider);
const privilegedRequester = new PrivilegedRequester(provider);
const runner = new Runner(pullRequest, privilegedRequester);

2
dist/index.js.map сгенерированный поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -4,17 +4,8 @@ import { PullRequest } from "./src/pull-request";
import { Runner } from "./src/runner";
const core = require("@actions/core");
let myToken = core.getInput("myToken");
const robotUserToken = core.getInput("robotUserToken");
if (
robotUserToken !== "" ||
robotUserToken !== undefined ||
robotUserToken !== null
) {
core.info("Robot User configured. I will use that PAT instead.");
myToken = robotUserToken;
}
const provider = new GitHubProvider(myToken);
const token = core.getInput("github_token", { required: true });
const provider = new GitHubProvider(token);
const pullRequest = new PullRequest(provider);
const privilegedRequester = new PrivilegedRequester(provider);
const runner = new Runner(pullRequest, privilegedRequester);