Skip to content
This repository was archived by the owner on Sep 13, 2025. It is now read-only.

Commit 7b9d356

Browse files
committed
Merge remote-tracking branch 'origin/master' into v3
2 parents 1750b50 + 2e159c5 commit 7b9d356

File tree

8 files changed

+342
-80
lines changed

8 files changed

+342
-80
lines changed

.github/workflows/star.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

__tests__/client.test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,61 @@ describe('8398a7/action-slack', () => {
142142
});
143143
});
144144

145+
// ensure if messages are specified, they're used
146+
describe('message is specified', () => {
147+
it('with success', async () => {
148+
const success_message = 'Woo hoo!';
149+
const withParams = {
150+
...newWith(),
151+
success_message,
152+
status: Success,
153+
};
154+
const client = new Client(
155+
withParams,
156+
gitHubToken,
157+
gitHubBaseUrl,
158+
webhookUrl,
159+
);
160+
const payload = getTemplate(withParams.fields, success_message);
161+
payload.attachments[0].color = 'good';
162+
expect(await client.prepare('')).toStrictEqual(payload);
163+
});
164+
it('with failure', async () => {
165+
const failure_message = "D'oh!";
166+
const withParams = {
167+
...newWith(),
168+
failure_message,
169+
status: Failure,
170+
};
171+
const client = new Client(
172+
withParams,
173+
gitHubToken,
174+
gitHubBaseUrl,
175+
webhookUrl,
176+
);
177+
const payload = getTemplate(withParams.fields, failure_message);
178+
payload.attachments[0].color = 'danger';
179+
expect(await client.prepare('')).toStrictEqual(payload);
180+
});
181+
it('with cancel', async () => {
182+
const cancelled_message = 'Why, you little!';
183+
const withParams = {
184+
...newWith(),
185+
cancelled_message,
186+
status: Cancelled,
187+
};
188+
const client = new Client(
189+
withParams,
190+
gitHubToken,
191+
gitHubBaseUrl,
192+
webhookUrl,
193+
);
194+
const payload = getTemplate(withParams.fields, cancelled_message);
195+
payload.attachments[0].color = 'warning';
196+
expect(await client.prepare('')).toStrictEqual(payload);
197+
});
198+
});
199+
145200
it('has no mention', async () => {
146201
const withParams = {
147202
...newWith(),

__tests__/helper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const setupNockJobs = (runId: string, fixture: string) =>
5151
});
5252

5353
export const successMsg = ':white_check_mark: Succeeded GitHub Actions\n';
54-
export const cancelMsg = ':warning: Canceled GitHub Actions\n';
54+
export const cancelMsg = ':warning: Cancelled GitHub Actions\n';
5555
export const failMsg = ':no_entry: Failed GitHub Actions\n';
5656
export const getApiFixture = (name: string): any =>
5757
JSON.parse(
@@ -70,6 +70,9 @@ export const newWith = (): With => {
7070
channel: '',
7171
fields: '',
7272
job_name: '',
73+
success_message: successMsg,
74+
cancelled_message: cancelMsg,
75+
failure_message: failMsg,
7376
};
7477
};
7578

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ inputs:
5858
description: Use this if you want to overwrite the job name.
5959
default: ""
6060
required: false
61+
success_message:
62+
description: Message to use when the status is 'success'.
63+
default: ":white_check_mark: Succeeded GitHub Actions\n"
64+
required: false
65+
cancelled_message:
66+
description: Message to use when the status is 'cancelled'.
67+
default: ":warning: Cancelled GitHub Actions\n"
68+
required: false
69+
failure_message:
70+
description: Message to use when the status is 'failure'.
71+
default: ":no_entry: Failed GitHub Actions\n"
72+
required: false
6173
github_token:
6274
description: Use this if you wish to use a different GitHub token than the one provided by the workflow.
6375
required: false

0 commit comments

Comments
 (0)