Deploy Production Code for Commit c30eaca625 🚀

This commit is contained in:
James Ives
2024-09-27 15:13:16 +00:00
parent c30eaca625
commit 4bcb0dacb6
3 changed files with 38 additions and 3 deletions

15
lib/execute.d.ts vendored
View File

@@ -1,5 +1,14 @@
/**
* The output of a command.
*/
type ExecuteOutput = {
/**
* The standard output of the command.
*/
stdout: string;
/**
* The standard error of the command.
*/
stderr: string;
};
/** Wrapper around the GitHub toolkit exec command which returns the output.
@@ -12,6 +21,12 @@ type ExecuteOutput = {
* on a non-zero exit status or to leave implementation up to the caller.
*/
export declare function execute(cmd: string, cwd: string, silent: boolean, ignoreReturnCode?: boolean): Promise<ExecuteOutput>;
/**
* Writes the output of a command to the stdout buffer.
*/
export declare function stdout(data: Buffer | string): void;
/**
* Writes the output of a command to the stderr buffer.
*/
export declare function stderr(data: Buffer | string): void;
export {};

View File

@@ -41,6 +41,9 @@ function execute(cmd_1, cwd_1, silent_1) {
return Promise.resolve(output);
});
}
/**
* Writes the output of a command to the stdout buffer.
*/
function stdout(data) {
const dataString = data.toString().trim();
if (output.stdout.length + dataString.length <
@@ -48,6 +51,9 @@ function stdout(data) {
output.stdout += dataString;
}
}
/**
* Writes the output of a command to the stderr buffer.
*/
function stderr(data) {
const dataString = data.toString().trim();
if (output.stderr.length + dataString.length <

View File

@@ -29,10 +29,24 @@ function init(action) {
try {
(0, core_1.info)(`Deploying using ${action.tokenType}… 🔑`);
(0, core_1.info)('Configuring git…');
/**
* Add safe directory to the global git config.
*/
try {
yield (0, execute_1.execute)(`git config --global safe.directory '*'`, action.workspace, action.silent);
}
catch (_a) {
(0, core_1.info)('Unable to set workflow file tree as a safe directory…');
}
/**
* Ensure that the workspace is a safe directory, this is somewhat redundant as the action
* will always set the workspace as a safe directory, but this is a fallback in case the action
* fails to do so.
*/
try {
yield (0, execute_1.execute)(`git config --global --add safe.directory "${action.workspace}"`, action.workspace, action.silent);
}
catch (_a) {
catch (_b) {
(0, core_1.info)('Unable to set workspace as a safe directory…');
}
yield (0, execute_1.execute)(`git config user.name "${action.name}"`, action.workspace, action.silent);
@@ -49,7 +63,7 @@ function init(action) {
throw new Error();
}
}
catch (_b) {
catch (_c) {
(0, core_1.info)('Unable to unset previous git config authentication as it may not exist, continuing…');
}
try {
@@ -58,7 +72,7 @@ function init(action) {
throw new Error();
}
}
catch (_c) {
catch (_d) {
(0, core_1.info)('Attempted to remove origin but failed, continuing…');
}
yield (0, execute_1.execute)(`git remote add origin ${action.repositoryPath}`, action.workspace, action.silent);