Skip to content

Commit

Permalink
feat: using github env
Browse files Browse the repository at this point in the history
  • Loading branch information
pam- committed Mar 2, 2021
1 parent f3af0c2 commit f233440
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
14 changes: 10 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11944,13 +11944,14 @@ module.exports = resolveCommand;
const { context } = __webpack_require__(469);

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName, job, runNumber, 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/', '');

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 =
event === 'pull_request'
Expand All @@ -11970,8 +11971,13 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
title: 'Action',
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}, ${job}, ${process.env.GITHUB_JOB} ${runNumber}, ${runId}>`,
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/run/${runId} | ${workflow}>`,
short: true,
},
{
title: 'Job',
value: `<https://github.com/${owner}/${repo}/actions/run/${runId} | ${job}>`,
short: true,
},
{
Expand Down
13 changes: 10 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const { context } = require('@actions/github');

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName, job, runNumber, 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/', '');

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 =
event === 'pull_request'
Expand All @@ -26,8 +28,13 @@ function buildSlackAttachments({ status, color, github }) {
color,
fields: [
{
title: 'Action',
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}, ${job}, ${process.env.GITHUB_JOB} ${runNumber}, ${runId}>`,
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/run/${runId} | ${workflow}>`,
short: true,
},
{
title: 'Job',
value: `<https://github.com/${owner}/${repo}/actions/run/${runId} | ${job}>`,
short: true,
},
{
Expand Down

0 comments on commit f233440

Please sign in to comment.