Skip to content

Commit

Permalink
feat: adding job name in Slack message
Browse files Browse the repository at this point in the history
syntax
  • Loading branch information
pam- committed Mar 1, 2021
1 parent a16c99c commit 8189fb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const GITHUB_PUSH_EVENT = {
workflow: 'CI',
eventName: 'push',
sha: 'abc123',
job: 'ci',
runId: 12345
},
};

Expand All @@ -33,5 +35,7 @@ export const GITHUB_PR_EVENT = {
workflow: 'CI',
eventName: 'pull_request',
sha: 'abc123',
job: 'ci',
runId: 12345
},
};
13 changes: 9 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { context } = require('@actions/github');
const { context } = require('@actions/github-script');

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName } = github.context;
const { payload, ref, workflow, eventName, job, runId } = github.context;
const { owner, repo } = context.repo;
const event = eventName;
const branch = event === 'pull_request' ? payload.pull_request.head.ref : ref.replace('refs/heads/', '');
Expand All @@ -26,8 +26,13 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
title: 'Action',
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}>`,
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId}/ | ${workflow}>`,
short: true,
},
{
title: 'Job',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId}/ | ${job}>`,
short: true,
},
{
Expand Down

0 comments on commit 8189fb3

Please sign in to comment.