From ba790c862c380240c6d5e7427be5ace9a05c754b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 7 Mar 2023 12:25:56 +0100 Subject: [PATCH] feat: default `repo-token` to `github.token` (#227) * feat: default `repo-token` to `github.token` * Update README.md * Update labeler.ts * Update index.js * Update action.yml * Update dist/index.js * Update index.js * Update dist/index.js --- README.md | 8 ++------ action.yml | 4 +++- dist/index.js | 2 +- src/labeler.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 78690ed8e..47bc342c7 100644 --- a/README.md +++ b/README.md @@ -99,21 +99,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/labeler@v4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" ``` -_Note: This grants access to the `GITHUB_TOKEN` so the action can make calls to GitHub's rest API_ - #### Inputs Various inputs are defined in [`action.yml`](action.yml) to let you configure the labeler: | Name | Description | Default | | - | - | - | -| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with `contents:read` and `pull-requests:write` access | N/A | +| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with `contents:read` and `pull-requests:write` access | `github.token` | | `configuration-path` | The path to the label configuration file | `.github/labeler.yml` | -| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false` +| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false`| # Contributions diff --git a/action.yml b/action.yml index 42e8a7a20..a3df342b6 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,9 @@ description: 'Automatically label new pull requests based on the paths of files author: 'GitHub' inputs: repo-token: - description: 'The GITHUB_TOKEN secret' + description: 'The GitHub token used to manage labels' + required: false + default: ${{ github.token }} configuration-path: description: 'The path for the label configurations' default: '.github/labeler.yml' diff --git a/dist/index.js b/dist/index.js index 4b521af64..014496405 100644 --- a/dist/index.js +++ b/dist/index.js @@ -47,7 +47,7 @@ const minimatch_1 = __nccwpck_require__(3973); function run() { return __awaiter(this, void 0, void 0, function* () { try { - const token = core.getInput('repo-token', { required: true }); + const token = core.getInput('repo-token'); const configPath = core.getInput('configuration-path', { required: true }); const syncLabels = !!core.getInput('sync-labels', { required: false }); const prNumber = getPrNumber(); diff --git a/src/labeler.ts b/src/labeler.ts index b33073adc..88bf64a48 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -13,7 +13,7 @@ type ClientType = ReturnType; export async function run() { try { - const token = core.getInput('repo-token', {required: true}); + const token = core.getInput('repo-token'); const configPath = core.getInput('configuration-path', {required: true}); const syncLabels = !!core.getInput('sync-labels', {required: false});