diff --git a/.github/workflows/label-commenter.yml b/.github/workflows/label-commenter.yml index cec0cc7b..0202a33e 100644 --- a/.github/workflows/label-commenter.yml +++ b/.github/workflows/label-commenter.yml @@ -23,7 +23,7 @@ jobs: ref: master - name: Label Commenter - uses: peaceiris/actions-label-commenter@v1.6.0 + uses: peaceiris/actions-label-commenter@v1.6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} # config_file: .github/label-commenter-config.yml diff --git a/src/main.ts b/src/main.ts index 1a4dfb71..df813831 100644 --- a/src/main.ts +++ b/src/main.ts @@ -127,16 +127,33 @@ export async function run(): Promise { } // Render template - const commentBodyView = { - issue: { - user: { - login: (context.payload as any).issue.user.login // eslint-disable-line @typescript-eslint/no-explicit-any - } - }, - sender: { - login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any + const commentBodyView = (() => { + if (eventName === 'issues') { + return { + issue: { + user: { + login: (context.payload as any).issue.user.login // eslint-disable-line @typescript-eslint/no-explicit-any + } + }, + sender: { + login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any + } + }; + } else if (eventName === 'pull_request' || eventName === 'pull_request_target') { + return { + pull_request: { + user: { + login: (context.payload as any).pull_request.user.login // eslint-disable-line @typescript-eslint/no-explicit-any + } + }, + sender: { + login: (context.payload as any).sender.login // eslint-disable-line @typescript-eslint/no-explicit-any + } + }; + } else { + return {}; } - }; + })(); const commentBodyRendered = Mustache.render(commentBody, commentBodyView); // Post comment