Skip to content

Commit

Permalink
feat: default repo-token to github.token (#227)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MichaelDeBoey authored Mar 7, 2023
1 parent b333851 commit ba790c8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ClientType = ReturnType<typeof github.getOctokit>;

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});

Expand Down

0 comments on commit ba790c8

Please sign in to comment.