Skip to content

Commit

Permalink
fix: removing job field
Browse files Browse the repository at this point in the history
  • Loading branch information
pam- committed Mar 1, 2021
1 parent 3055472 commit 4bd2941
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 37 deletions.
22 changes: 6 additions & 16 deletions __tests__/utils.spec.js
Expand Up @@ -33,19 +33,9 @@ describe('Utils', () => {
it('links to the action workflow', () => {
const attachments = buildSlackAttachments({ status: 'STARTED', color: 'good', github: GITHUB_PUSH_EVENT });

expect(attachments[0].fields.find(a => a.title === 'Workflow')).toEqual({
title: 'Workflow',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/actions/runs/12345 | CI>`,
short: true,
});
});

it('links to the action job', () => {
const attachments = buildSlackAttachments({ status: 'STARTED', color: 'good', github: GITHUB_PUSH_EVENT });

expect(attachments[0].fields.find(a => a.title === 'Job')).toEqual({
title: 'Job',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/actions/runs/12345 | build and push>`,
expect(attachments[0].fields.find(a => a.title === 'Action')).toEqual({
title: 'Action',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/commit/abc123/checks | CI>`,
short: true,
});
});
Expand Down Expand Up @@ -75,9 +65,9 @@ describe('Utils', () => {
it('links to the action workflow', () => {
const attachments = buildSlackAttachments({ status: 'STARTED', color: 'good', github: GITHUB_PR_EVENT });

expect(attachments[0].fields.find(a => a.title === 'Workflow')).toEqual({
title: 'Workflow',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/actions/runs/12345 | CI>`,
expect(attachments[0].fields.find(a => a.title === 'Action')).toEqual({
title: 'Action',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/commit/xyz678/checks | CI>`,
short: true,
});
});
Expand Down
13 changes: 4 additions & 9 deletions dist/index.js
Expand Up @@ -10002,7 +10002,7 @@ module.exports = resolveCommand;
const { context } = __webpack_require__(469);

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName, job, runId } = github.context;
const { payload, ref, workflow, eventName } = 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 @@ -10027,13 +10027,8 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
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}>`,
title: 'Action',
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}>`,
short: true,
},
{
Expand Down Expand Up @@ -18432,4 +18427,4 @@ RetryOperation.prototype.mainError = function() {

/***/ })

/******/ });
/******/ });
4 changes: 0 additions & 4 deletions fixtures.js
Expand Up @@ -14,8 +14,6 @@ export const GITHUB_PUSH_EVENT = {
workflow: 'CI',
eventName: 'push',
sha: 'abc123',
job: 'build and push',
runId: 12345,
},
};

Expand All @@ -35,7 +33,5 @@ export const GITHUB_PR_EVENT = {
workflow: 'CI',
eventName: 'pull_request',
sha: 'abc123',
job: 'build and push',
runId: 12345,
},
};
11 changes: 3 additions & 8 deletions src/utils.js
@@ -1,7 +1,7 @@
const { context } = require('@actions/github');

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName, job, runId } = github.context;
const { payload, ref, workflow, eventName } = 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,13 +26,8 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
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}>`,
title: 'Action',
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}>`,
short: true,
},
{
Expand Down

0 comments on commit 4bd2941

Please sign in to comment.