From 226e184a981ed2feee11ff1e3b03185e7ed6a4c1 Mon Sep 17 00:00:00 2001 From: homoluctus Date: Mon, 16 Sep 2019 05:34:43 +0900 Subject: [PATCH] fix: workflow link is invalid when event name is pull_request --- lib/slack.js | 9 ++++++++- src/slack.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/slack.js b/lib/slack.js index b76fc7619..2a04df938 100644 --- a/lib/slack.js +++ b/lib/slack.js @@ -29,8 +29,15 @@ class Slack extends webhook_1.IncomingWebhook { const context = github.context; const { sha, eventName, workflow, ref } = context; const { owner, repo } = context.repo; + const { number } = context.issue; const repo_url = `https://github.com/${owner}/${repo}`; - const action_url = `${repo_url}/commit/${sha}/checks`; + let action_url = repo_url; + if (eventName === 'pull_request') { + action_url += `/pull/${number}/checks`; + } + else { + action_url += `/commit/${sha}/checks`; + } const blocks = { type: 'section', fields: [ diff --git a/src/slack.ts b/src/slack.ts index 4576dfe14..865e3205b 100644 --- a/src/slack.ts +++ b/src/slack.ts @@ -29,8 +29,15 @@ export class Slack extends IncomingWebhook { const context = github.context; const { sha, eventName, workflow, ref } = context; const { owner, repo } = context.repo; + const { number } = context.issue; const repo_url: string = `https://github.com/${owner}/${repo}`; - const action_url: string = `${repo_url}/commit/${sha}/checks`; + let action_url: string = repo_url; + + if (eventName === 'pull_request') { + action_url += `/pull/${number}/checks` + } else { + action_url += `/commit/${sha}/checks`; + } const blocks: SectionBlock = { type: 'section',