Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix owner/repo fetching #7

Merged
merged 6 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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