Skip to content

Commit

Permalink
Merge pull request #7 from voxmedia/jl-fix-owner-repo
Browse files Browse the repository at this point in the history
Fix owner/repo fetching
  • Loading branch information
CGeohagan committed Jan 17, 2020
2 parents 99e5a63 + 1624c2a commit 5125947
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: GitHub Action Slack Notify CI

on: [push]
on:
- push
- pull_request

jobs:
build:
Expand All @@ -18,7 +20,7 @@ jobs:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: ./
with:
channel: 'rp-notifications'
channel_id: CB9QT2NNR
status: STARTED
color: warning
- name: Get yarn cache
Expand All @@ -42,6 +44,6 @@ jobs:
uses: ./
with:
message_id: ${{ steps.slack.outputs.message_id }}
channel: 'rp-notifications'
channel_id: CB9QT2NNR
status: SUCCESS
color: good
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Fixes bug where owner/repo can not be determined with certain events (like scheduled jobs)

# v1.1.0 - 11/19/2019

- Add footer containing repo and timestamp
Expand Down
13 changes: 7 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9753,12 +9753,13 @@ function hasFirstPage (link) {
/***/ }),

/***/ 543:
/***/ (function(module) {
/***/ (function(module, __unusedexports, __webpack_require__) {

const { context } = __webpack_require__(469);

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName } = github.context;
const owner = payload.repository.owner.login;
const name = payload.repository.name;
const { owner, repo } = context.repo;
const event = eventName;
const branch = event === 'pull_request' ? payload.pull_request.head.ref : ref.replace('refs/heads/', '');

Expand All @@ -9773,7 +9774,7 @@ function buildSlackAttachments({ status, color, github }) {
}
: {
title: 'Branch',
value: `<https://github.com/${owner}/${name}/commit/${sha} | ${branch}>`,
value: `<https://github.com/${owner}/${repo}/commit/${sha} | ${branch}>`,
short: true,
};

Expand All @@ -9783,7 +9784,7 @@ function buildSlackAttachments({ status, color, github }) {
fields: [
{
title: 'Action',
value: `<https://github.com/${owner}/${name}/commit/${sha}/checks | ${workflow}>`,
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}>`,
short: true,
},
{
Expand All @@ -9799,7 +9800,7 @@ function buildSlackAttachments({ status, color, github }) {
},
],
footer_icon: 'https://github.githubassets.com/favicon.ico',
footer: `<https://github.com/${owner}/${name} | ${owner}/${name}>`,
footer: `<https://github.com/${owner}/${repo} | ${owner}/${repo}>`,
ts: Math.floor(Date.now() / 1000),
},
];
Expand Down
11 changes: 6 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { context } = require('@actions/github');

function buildSlackAttachments({ status, color, github }) {
const { payload, ref, workflow, eventName } = github.context;
const owner = payload.repository.owner.login;
const name = payload.repository.name;
const { owner, repo } = context.repo;
const event = eventName;
const branch = event === 'pull_request' ? payload.pull_request.head.ref : ref.replace('refs/heads/', '');

Expand All @@ -16,7 +17,7 @@ function buildSlackAttachments({ status, color, github }) {
}
: {
title: 'Branch',
value: `<https://github.com/${owner}/${name}/commit/${sha} | ${branch}>`,
value: `<https://github.com/${owner}/${repo}/commit/${sha} | ${branch}>`,
short: true,
};

Expand All @@ -26,7 +27,7 @@ function buildSlackAttachments({ status, color, github }) {
fields: [
{
title: 'Action',
value: `<https://github.com/${owner}/${name}/commit/${sha}/checks | ${workflow}>`,
value: `<https://github.com/${owner}/${repo}/commit/${sha}/checks | ${workflow}>`,
short: true,
},
{
Expand All @@ -42,7 +43,7 @@ function buildSlackAttachments({ status, color, github }) {
},
],
footer_icon: 'https://github.githubassets.com/favicon.ico',
footer: `<https://github.com/${owner}/${name} | ${owner}/${name}>`,
footer: `<https://github.com/${owner}/${repo} | ${owner}/${repo}>`,
ts: Math.floor(Date.now() / 1000),
},
];
Expand Down

0 comments on commit 5125947

Please sign in to comment.