From 48c03e160dc7b2f5202b9ae2bd371bc65a303823 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Mar 2020 05:37:21 +0900 Subject: [PATCH] fix: pr number --- .github/workflows/commenter.yml | 2 +- src/main.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/commenter.yml b/.github/workflows/commenter.yml index 5c08f44b..f3bd1cf0 100644 --- a/.github/workflows/commenter.yml +++ b/.github/workflows/commenter.yml @@ -18,7 +18,7 @@ jobs: with: ref: master - name: Commenter - uses: peaceiris/actions-label-commenter@v0.3.1 + uses: peaceiris/actions-label-commenter@v0.3.2 with: github_token: ${{ secrets.GITHUB_TOKEN }} config_file: .github/commenter_test_1.yml diff --git a/src/main.ts b/src/main.ts index 559b23e3..d03397ab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -37,11 +37,19 @@ export async function run(): Promise { console.log(context); + const eventName = context.eventName; const labelEvent = context.payload.action; // eslint-disable-next-line @typescript-eslint/no-explicit-any const labelName = (context.payload as any).label.name; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const issueNumber = (context.payload as any).issue.number; + let issueNumber = ''; + if (eventName === 'issues') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + issueNumber = (context.payload as any).issue.number; + } else if (eventName === 'pull_request') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + issueNumber = (context.payload as any).number; + } + core.info(`\ [INFO] config_file: ${inps.ConfigFilePath} [INFO] labelName: ${labelName} @@ -83,7 +91,6 @@ export async function run(): Promise { ); } - const eventName = context.eventName; let eventType = ''; if (eventName === 'issues') { eventType = 'issue';