Skip to content

Commit

Permalink
feat: putting repo name more prominently
Browse files Browse the repository at this point in the history
  • Loading branch information
pam- committed Mar 3, 2021
1 parent d906713 commit 373da97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 4 additions & 5 deletions __tests__/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { formatChannelName, buildSlackAttachments } from '../src/utils';
import { GITHUB_PUSH_EVENT, GITHUB_PR_EVENT } from '../fixtures';
const runId = parseInt(process.env.GITHUB_RUN_ID, 10);
const job = process.env.GITHUB_JOB;

describe('Utils', () => {
describe('formatChannelName', () => {
Expand Down Expand Up @@ -42,12 +41,12 @@ describe('Utils', () => {
});
});

it('links to the action job', () => {
it('links to the action repo', () => {
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/${runId} | ${job}>`,
expect(attachments[0].fields.find(a => a.title === 'Repo')).toEqual({
title: 'Repo',
value: `<https://github.com/voxmedia/github-action-slack-notify-build | voxmedia/github-action-slack-notify-build>`,
short: true,
});
});
Expand Down
9 changes: 4 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11950,7 +11950,6 @@ function buildSlackAttachments({ status, color, github }) {
const branch = event === 'pull_request' ? payload.pull_request.head.ref : ref.replace('refs/heads/', '');

const sha = event === 'pull_request' ? payload.pull_request.head.sha : github.context.sha;
const job = process.env.GITHUB_JOB;
const runId = parseInt(process.env.GITHUB_RUN_ID, 10);

const referenceLink =
Expand All @@ -11971,13 +11970,13 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${workflow}>`,
title: 'Repo',
value: `<https://github.com/${owner}/${repo} | ${owner}/${repo}>`,
short: true,
},
{
title: 'Job',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${job}>`,
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${workflow}>`,
short: true,
},
{
Expand Down
9 changes: 4 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function buildSlackAttachments({ status, color, github }) {
const branch = event === 'pull_request' ? payload.pull_request.head.ref : ref.replace('refs/heads/', '');

const sha = event === 'pull_request' ? payload.pull_request.head.sha : github.context.sha;
const job = process.env.GITHUB_JOB;
const runId = parseInt(process.env.GITHUB_RUN_ID, 10);

const referenceLink =
Expand All @@ -28,13 +27,13 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${workflow}>`,
title: 'Repo',
value: `<https://github.com/${owner}/${repo} | ${owner}/${repo}>`,
short: true,
},
{
title: 'Job',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${job}>`,
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${workflow}>`,
short: true,
},
{
Expand Down

0 comments on commit 373da97

Please sign in to comment.