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

Prints output of exec to the current process' stdout, stderr, & stdline #139

Merged
merged 10 commits into from
Feb 21, 2024
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
47 changes: 37 additions & 10 deletions dist/index.js
rhahao marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class OidcClient {
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`);
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
Expand Down Expand Up @@ -4082,24 +4082,51 @@ const run = async () => {
const config = process.env.config;

// check only deployment settings
let deployOnly = process.env.function === 'true' ? 'function' : '';
deployOnly += deployOnly === '' ? '' : ' ';
deployOnly += process.env.hosting === 'true' ? `hosting` : '';
let deployList = [];

let cmd = `firebase deploy -m ${process.env.GITHUB_SHA}`;
cmd += config ? ` --config ${config}` : ' ';
cmd += ` --project ${project}`;
cmd += deployOnly !== '' ? ` --only ${deployOnly}` : '';
if (process.env.function === 'true') {
deployList.push('functions');
}

if (process.env.hosting === 'true') {
deployList.push('hosting');
}

let args = ['deploy', '-m', process.env.GITHUB_SHA, '--project', project];

if (config) {
args.push('--config', config);
}

if (deployList.length > 0) {
args.push('--only', deployList.join(','));
}

const options = {};
options.listeners = {
stdout: (data) => {
process.stdout.write(data.toString());
},
stderr: (data) => {
process.stderr.write(data.toString());
},
stdline: (data) => {
process.stdline.write(data.toString());
},
};

try {
// attempt to run firebase deploy, and run with debug mode if failed
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(cmd);
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("firebase", args, options);

} catch (error) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.error(`An error occured while deploying to Firebase: ${error}. Retrying with debug mode enabled ...`);

// attempt to run firebase deploy with debug mode
args.push("--debug");

try {
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`${cmd} --debug`);
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("firebase", args, options);
} catch (error) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(`An error occured while deploying to Firebase: ${error}`);
}
Expand Down
45 changes: 36 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,51 @@ const run = async () => {
const config = process.env.config;

// check only deployment settings
let deployOnly = process.env.function === 'true' ? 'function' : '';
deployOnly += deployOnly === '' ? '' : ' ';
deployOnly += process.env.hosting === 'true' ? `hosting` : '';
let deployList = [];

let cmd = `firebase deploy -m ${process.env.GITHUB_SHA}`;
cmd += config ? ` --config ${config}` : ' ';
cmd += ` --project ${project}`;
cmd += deployOnly !== '' ? ` --only ${deployOnly}` : '';
if (process.env.function === 'true') {
deployList.push('functions');
}

if (process.env.hosting === 'true') {
deployList.push('hosting');
}

let args = ['deploy', '-m', process.env.GITHUB_SHA, '--project', project];

if (config) {
args.push('--config', config);
}

if (deployList.length > 0) {
args.push('--only', deployList.join(','));
}

const options = {};
options.listeners = {
stdout: (data) => {
process.stdout.write(data.toString());
},
stderr: (data) => {
process.stderr.write(data.toString());
},
stdline: (data) => {
process.stdline.write(data.toString());
},
};

try {
// attempt to run firebase deploy, and run with debug mode if failed
await exec.exec(cmd);
await exec.exec("firebase", args, options);

} catch (error) {
core.error(`An error occured while deploying to Firebase: ${error}. Retrying with debug mode enabled ...`);

// attempt to run firebase deploy with debug mode
args.push("--debug");

try {
await exec.exec(`${cmd} --debug`);
await exec.exec("firebase", args, options);
} catch (error) {
core.setFailed(`An error occured while deploying to Firebase: ${error}`);
}
Expand Down
Loading