Skip to content

Commit 3250777

Browse files
authored
Hotfix: Fix issues that do not allow the build process to run (#9)
1 parent 3222a24 commit 3250777

File tree

4 files changed

+68
-23
lines changed

4 files changed

+68
-23
lines changed

dist/index.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27263,28 +27263,48 @@ async function run() {
2726327263
const slack = slackWebhookUrl ? new Slack(slackWebhookUrl) : null;
2726427264
const vercel = new Vercel(vercelTokenId);
2726527265
try {
27266-
if (slackStartPayloadFile)
27266+
if (slackStartPayloadFile) {
27267+
core.info('Exporting Starting message...');
2726727268
slackStartPayload = await jsonReader.read(slackStartPayloadFile);
27268-
if (slackSuccessPayloadFile)
27269-
slackSuccessPayload = await jsonReader.read(slackSuccessPayloadFile);
27270-
if (slack !== null && slackStartPayload)
27269+
core.info('Exported Starting message!');
27270+
}
27271+
if (slackSuccessPayloadFile) {
27272+
core.group('Get Succeed message for Slack Notification from File', async () => {
27273+
core.info('Exporting Succeed message...');
27274+
slackSuccessPayload = await jsonReader.read(slackSuccessPayloadFile);
27275+
core.info('Exported Succeed message!');
27276+
});
27277+
}
27278+
if (slack !== null && slackStartPayload) {
27279+
core.info('Send Starting message to Slack');
2727127280
await slack.send(slackStartPayload);
27281+
}
27282+
core.info('processing deploy to Vercel');
2727227283
await vercel.pull();
2727327284
await vercel.build();
2727427285
await vercel.deploy();
27286+
core.info('Send Succeed message to Slack');
2727527287
if (slack !== null && slackSuccessPayload)
2727627288
await slack.send(slackSuccessPayload);
27289+
core.info('All processes are done!');
2727727290
core.setOutput('process-time', runtimeCounter.stop());
2727827291
}
2727927292
catch (error) {
2728027293
if (error instanceof Error) {
2728127294
core.setFailed(error.message);
27282-
if (slackFailurePayloadFile)
27283-
slackFailurePayload = await jsonReader.read(slackFailurePayloadFile);
27284-
if (slack !== null && slackFailurePayload)
27285-
slack.send(slackFailurePayload);
2728627295
}
27296+
else if (typeof error === 'string') {
27297+
core.setFailed(error);
27298+
}
27299+
else {
27300+
core.setFailed('Deploy failed!');
27301+
}
27302+
if (slackFailurePayloadFile)
27303+
slackFailurePayload = await jsonReader.read(slackFailurePayloadFile);
27304+
if (slack !== null && slackFailurePayload)
27305+
slack.send(slackFailurePayload);
2728727306
}
2728827307
}
27308+
run();
2728927309

27290-
export { run as default };
27310+
export { run };

dist/utils/Slack.util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Slack {
1212
}
1313
send(payload) {
1414
return new Promise((resolve, reject) => {
15-
child.exec(`curl -X POST -H 'Content-type: application/json' --data '${payload}'`, (error, stdout) => {
15+
child.exec(`curl -X POST -H 'Content-type: application/json' --data '${payload}' ${this.webhookUrl}`, (error, stdout) => {
1616
if (error) {
1717
reject(`Failed send slack message: ${error}`);
1818
return;

src/index.ts

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { RuntimeCounter } from './utils/RuntimeCounter.util';
55
import { JsonReader } from './utils/JsonReader.util';
66
import { GithubPath } from './utils/GithubPath.util';
77

8-
async function run() {
8+
export type IDependencies = {
9+
githubPath: GithubPath;
10+
slack: Slack;
11+
vercel: Vercel;
12+
jsonReader: JsonReader;
13+
runtimeCounter: RuntimeCounter;
14+
}
15+
16+
export async function run() {
917
const jsonReader = new JsonReader();
1018
const runtimeCounter = new RuntimeCounter();
1119
runtimeCounter.start();
@@ -24,34 +32,51 @@ async function run() {
2432
const slack = slackWebhookUrl ? new Slack(slackWebhookUrl) : null;
2533
const vercel = new Vercel(vercelTokenId);
2634

27-
try {
28-
if (slackStartPayloadFile)
35+
try {
36+
if (slackStartPayloadFile) {
37+
core.info('Exporting Starting message...');
2938
slackStartPayload = await jsonReader.read(slackStartPayloadFile) as string;
30-
if (slackSuccessPayloadFile)
31-
slackSuccessPayload = await jsonReader.read(slackSuccessPayloadFile) as string;
39+
core.info('Exported Starting message!');
40+
}
41+
if (slackSuccessPayloadFile) {
42+
core.group('Get Succeed message for Slack Notification from File', async () => {
43+
core.info('Exporting Succeed message...');
44+
slackSuccessPayload = await jsonReader.read(slackSuccessPayloadFile) as string;
45+
core.info('Exported Succeed message!');
46+
});
47+
}
3248

33-
if (slack !== null && slackStartPayload)
49+
if (slack !== null && slackStartPayload) {
50+
core.info('Send Starting message to Slack');
3451
await slack.send(slackStartPayload);
52+
}
3553

54+
core.info('processing deploy to Vercel');
3655
await vercel.pull();
3756
await vercel.build();
3857
await vercel.deploy();
3958

59+
core.info('Send Succeed message to Slack');
4060
if (slack !== null && slackSuccessPayload)
4161
await slack.send(slackSuccessPayload);
4262

63+
core.info('All processes are done!');
4364
core.setOutput('process-time', runtimeCounter.stop());
4465
} catch (error) {
4566
if (error instanceof Error) {
4667
core.setFailed(error.message);
68+
} else if (typeof error === 'string') {
69+
core.setFailed(error);
70+
} else {
71+
core.setFailed('Deploy failed!');
72+
}
4773

48-
if (slackFailurePayloadFile)
49-
slackFailurePayload = await jsonReader.read(slackFailurePayloadFile) as string;
74+
if (slackFailurePayloadFile)
75+
slackFailurePayload = await jsonReader.read(slackFailurePayloadFile) as string;
5076

51-
if (slack !== null && slackFailurePayload)
52-
slack.send(slackFailurePayload);
53-
}
77+
if (slack !== null && slackFailurePayload)
78+
slack.send(slackFailurePayload);
5479
}
5580
}
5681

57-
export default run;
82+
run();

src/utils/Slack.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Slack {
1010
send(payload: string) {
1111
return new Promise((resolve, reject) => {
1212
child.exec(
13-
`curl -X POST -H 'Content-type: application/json' --data '${payload}'`,
13+
`curl -X POST -H 'Content-type: application/json' --data '${payload}' ${this.webhookUrl}`,
1414
(error, stdout) => {
1515
if (error) {
1616
reject(`Failed send slack message: ${error}`);

0 commit comments

Comments
 (0)