Skip to content

Commit

Permalink
fix: workflow link is invalid when event name is pull_request
Browse files Browse the repository at this point in the history
  • Loading branch information
homoluctus committed Sep 15, 2019
1 parent ca5581c commit 226e184
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
9 changes: 8 additions & 1 deletion src/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 226e184

Please sign in to comment.