Skip to content

Commit

Permalink
Merge pull request #44 from voxmedia/add-repo-field
Browse files Browse the repository at this point in the history
Putting repo name more prominently
  • Loading branch information
Pam Assogba authored Mar 5, 2021
2 parents aa21305 + 7d5c698 commit e86a116
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ jobs:
- name: yarn build
run: yarn build
- name: release
if: ${{ endsWith(github.ref, '/main') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: update v1 tag
if: ${{ endsWith(github.ref, '/main') }}
run: 'git push -f https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v1'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
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 @@ -10008,7 +10008,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 @@ -10029,13 +10028,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 e86a116

Please sign in to comment.