From 17041f94b72a3643c833fb94bd05405fd39f82bb Mon Sep 17 00:00:00 2001 From: Timon van Spronsen Date: Wed, 16 Nov 2022 15:30:51 +0100 Subject: [PATCH] Allow repo token to be passed in `with` section --- action.yml | 5 ++++- src/action.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index a41ce35b..4d825591 100644 --- a/action.yml +++ b/action.yml @@ -2,8 +2,11 @@ name: 'PR Labeler' description: 'Automatically labels your PRs based on branch name patterns like feature/* or fix/*.' author: 'Timon van Spronsen' inputs: + repo-token: + description: 'Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`' + default: ${{ github.token }} configuration-path: - description: 'The path for the label configurations' + description: 'Path to label configurations' default: '.github/pr-labeler.yml' branding: icon: 'tag' diff --git a/src/action.ts b/src/action.ts index 1ef77b32..a042f434 100644 --- a/src/action.ts +++ b/src/action.ts @@ -12,7 +12,7 @@ const defaultConfig = { async function action(context: Context = github.context) { try { - const GITHUB_TOKEN = process.env.GITHUB_TOKEN!; + const GITHUB_TOKEN = process.env.GITHUB_TOKEN ?? core.getInput('repo-token', { required: true }); const octokit = github.getOctokit(GITHUB_TOKEN).rest; const configPath = core.getInput('configuration-path', { required: true });