Skip to content

Commit

Permalink
Deploy Production Code for Commit c30eaca 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Sep 27, 2024
1 parent c30eaca commit 4bcb0da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
15 changes: 15 additions & 0 deletions lib/execute.d.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 {};
6 changes: 6 additions & 0 deletions lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ 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 <
buffer_1.default.constants.MAX_STRING_LENGTH) {
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 <
Expand Down
20 changes: 17 additions & 3 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 --add safe.directory "${action.workspace}"`, action.workspace, action.silent);
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 (_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);
Expand All @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit 4bcb0da

Please sign in to comment.