Skip to content

Commit

Permalink
v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sarisia committed May 4, 2020
1 parent 5257853 commit 453aa0d
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 155 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ jobs:
webhook: ${{ secrets.DISCORD_WEBHOOK2 }}
- run: sleep 1

- name: Test invalid webhook
uses: ./
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_INVALID }}
- run: sleep 1

- name: Test invalid webhook endpoint
uses: ./
if: always()
with:
webhook: "https://invalid.sarisia"
- run: sleep 1

- name: Test job
uses: ./
if: always()
Expand All @@ -39,19 +53,25 @@ jobs:
description: Test description
- run: sleep 1

- name: Test nofail
- name: Test status
uses: ./
if: always()
with:
status: ''
nofail: 'false'
status: ${{ job.status }}
- run: sleep 1

- name: Test status
- name: Test nodetail
uses: ./
if: always()
with:
status: ${{ job.status }}
nodetail: true
- run: sleep 1

- name: Test nodetail title
uses: ./
with:
nodetail: true
job: "title test"
- run: sleep 1

- name: Test color override
Expand All @@ -67,3 +87,12 @@ jobs:
with:
username: GitHub Actions
avatar_url: ${{ secrets.AVATAR_URL }}
- run: sleep 1

- name: Test nofail
uses: ./
if: always()
with:
status: ''
nofail: 'false'
- run: sleep 1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

A Github Actions action to notify CI status to Discord.

<img src="https://user-images.githubusercontent.com/33576079/69472655-332b2880-0df0-11ea-9c33-6add9fca62e9.png" width="500px">
<img width="478" alt="Screen Shot 2020-04-28 at 6 46 57" src="https://user-images.githubusercontent.com/33576079/80424271-55cfe900-891c-11ea-8c18-4cdcb1ce1ecf.png">

## Usage

Expand Down
13 changes: 11 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ function run() {
yield axios_1.default.post(webhook, getPayload(status, description, job, color, username, avatar_url, nodetail));
}
catch (e) {
logError(e, nofail);
logError("Failed to execute webhook:", nofail);
if (e.response) {
logError(`${e.response.status}: ${JSON.stringify(e.response.data)}`, nofail);
}
else {
logError(e, nofail);
}
}
});
}
Expand Down Expand Up @@ -98,14 +104,17 @@ function getPayload(status, description, job, color, username, avatar_url, nodet
core.debug(`Failed to generate eventDetail: ${error}\n${error.stack}`);
}
let embed = {
title: statusOpts[status].status + (job ? `: ${job}` : ''),
color: color || statusOpts[status].color,
timestamp: (new Date()).toISOString()
};
if (job) {
embed.title = job;
}
if (description) {
embed.description = description;
}
if (!nodetail) {
embed.title = statusOpts[status].status + (embed.title ? `: ${embed.title}` : '');
embed.fields = [
{
name: 'Repository',
Expand Down
Loading

0 comments on commit 453aa0d

Please sign in to comment.