Skip to content

Commit 9fc9677

Browse files
authored
fix(actions): update deploy command and print output of exec to the current process
1 parent 1755ac7 commit 9fc9677

File tree

2 files changed

+73
-19
lines changed

2 files changed

+73
-19
lines changed

dist/index.js

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class OidcClient {
554554
.catch(error => {
555555
throw new Error(`Failed to get ID Token. \n
556556
Error Code : ${error.statusCode}\n
557-
Error Message: ${error.result.message}`);
557+
Error Message: ${error.message}`);
558558
});
559559
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
560560
if (!id_token) {
@@ -4082,24 +4082,51 @@ const run = async () => {
40824082
const config = process.env.config;
40834083

40844084
// check only deployment settings
4085-
let deployOnly = process.env.function === 'true' ? 'function' : '';
4086-
deployOnly += deployOnly === '' ? '' : ' ';
4087-
deployOnly += process.env.hosting === 'true' ? `hosting` : '';
4085+
let deployList = [];
40884086

4089-
let cmd = `firebase deploy -m ${process.env.GITHUB_SHA}`;
4090-
cmd += config ? ` --config ${config}` : ' ';
4091-
cmd += ` --project ${project}`;
4092-
cmd += deployOnly !== '' ? ` --only ${deployOnly}` : '';
4087+
if (process.env.function === 'true') {
4088+
deployList.push('functions');
4089+
}
4090+
4091+
if (process.env.hosting === 'true') {
4092+
deployList.push('hosting');
4093+
}
4094+
4095+
let args = ['deploy', '-m', process.env.GITHUB_SHA, '--project', project];
4096+
4097+
if (config) {
4098+
args.push('--config', config);
4099+
}
4100+
4101+
if (deployList.length > 0) {
4102+
args.push('--only', deployList.join(','));
4103+
}
4104+
4105+
const options = {};
4106+
options.listeners = {
4107+
stdout: (data) => {
4108+
process.stdout.write(data.toString());
4109+
},
4110+
stderr: (data) => {
4111+
process.stderr.write(data.toString());
4112+
},
4113+
stdline: (data) => {
4114+
process.stdline.write(data.toString());
4115+
},
4116+
};
40934117

40944118
try {
40954119
// attempt to run firebase deploy, and run with debug mode if failed
4096-
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(cmd);
4120+
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("firebase", args, options);
4121+
40974122
} catch (error) {
40984123
_actions_core__WEBPACK_IMPORTED_MODULE_0__.error(`An error occured while deploying to Firebase: ${error}. Retrying with debug mode enabled ...`);
40994124

41004125
// attempt to run firebase deploy with debug mode
4126+
args.push("--debug");
4127+
41014128
try {
4102-
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`${cmd} --debug`);
4129+
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("firebase", args, options);
41034130
} catch (error) {
41044131
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(`An error occured while deploying to Firebase: ${error}`);
41054132
}

src/index.js

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,51 @@ const run = async () => {
1414
const config = process.env.config;
1515

1616
// check only deployment settings
17-
let deployOnly = process.env.function === 'true' ? 'function' : '';
18-
deployOnly += deployOnly === '' ? '' : ' ';
19-
deployOnly += process.env.hosting === 'true' ? `hosting` : '';
17+
let deployList = [];
2018

21-
let cmd = `firebase deploy -m ${process.env.GITHUB_SHA}`;
22-
cmd += config ? ` --config ${config}` : ' ';
23-
cmd += ` --project ${project}`;
24-
cmd += deployOnly !== '' ? ` --only ${deployOnly}` : '';
19+
if (process.env.function === 'true') {
20+
deployList.push('functions');
21+
}
22+
23+
if (process.env.hosting === 'true') {
24+
deployList.push('hosting');
25+
}
26+
27+
let args = ['deploy', '-m', process.env.GITHUB_SHA, '--project', project];
28+
29+
if (config) {
30+
args.push('--config', config);
31+
}
32+
33+
if (deployList.length > 0) {
34+
args.push('--only', deployList.join(','));
35+
}
36+
37+
const options = {};
38+
options.listeners = {
39+
stdout: (data) => {
40+
process.stdout.write(data.toString());
41+
},
42+
stderr: (data) => {
43+
process.stderr.write(data.toString());
44+
},
45+
stdline: (data) => {
46+
process.stdline.write(data.toString());
47+
},
48+
};
2549

2650
try {
2751
// attempt to run firebase deploy, and run with debug mode if failed
28-
await exec.exec(cmd);
52+
await exec.exec("firebase", args, options);
53+
2954
} catch (error) {
3055
core.error(`An error occured while deploying to Firebase: ${error}. Retrying with debug mode enabled ...`);
3156

3257
// attempt to run firebase deploy with debug mode
58+
args.push("--debug");
59+
3360
try {
34-
await exec.exec(`${cmd} --debug`);
61+
await exec.exec("firebase", args, options);
3562
} catch (error) {
3663
core.setFailed(`An error occured while deploying to Firebase: ${error}`);
3764
}

0 commit comments

Comments
 (0)