Skip to content

Commit

Permalink
Deploy Production Code for Commit d418023 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed May 10, 2021
1 parent d418023 commit fc8c70c
Show file tree
Hide file tree
Showing 67 changed files with 937 additions and 541 deletions.
5 changes: 3 additions & 2 deletions lib/execute.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/// <reference types="node" />
/** Wrapper around the GitHub toolkit exec command which returns the output.
* Also allows you to easily toggle the current working directory.
*
* @param {string} cmd - The command to execute.
* @param {string} cwd - The current working directory.
* @param {boolean} silent - Determines if the in/out should be silenced or not.
*/
export declare function execute(cmd: string, cwd: string, silent: boolean): Promise<any>;
export declare function stdout(data: any): string | void;
export declare function execute(cmd: string, cwd: string, silent: boolean): Promise<string>;
export declare function stdout(data: Buffer | string): void;
10 changes: 8 additions & 2 deletions lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stdout = exports.execute = void 0;
const exec_1 = require("@actions/exec");
let output;
const buffer_1 = __importDefault(require("buffer"));
let output = '';
/** Wrapper around the GitHub toolkit exec command which returns the output.
* Also allows you to easily toggle the current working directory.
*
Expand All @@ -35,6 +39,8 @@ function execute(cmd, cwd, silent) {
}
exports.execute = execute;
function stdout(data) {
output += data.toString().trim();
if (output.length < buffer_1.default.constants.MAX_STRING_LENGTH) {
output += data.toString().trim();
}
}
exports.stdout = stdout;
11 changes: 9 additions & 2 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function deploy(action) {
: ''} 🚀`;
// Checks to see if the remote exists prior to deploying.
const branchExists = action.isTest & constants_1.TestFlag.HAS_REMOTE_BRANCH ||
(yield execute_1.execute(`git ls-remote --heads ${action.repositoryPath} ${action.branch}`, action.workspace, action.silent));
(yield execute_1.execute(`git ls-remote --heads ${action.repositoryPath} refs/heads/${action.branch}`, action.workspace, action.silent));
yield worktree_1.generateWorktree(action, temporaryDeploymentDirectory, branchExists);
// Ensures that items that need to be excluded from the clean job get parsed.
let excludes = '';
Expand Down Expand Up @@ -115,7 +115,9 @@ function deploy(action) {
const hasFilesToCommit = action.isTest & constants_1.TestFlag.HAS_CHANGED_FILES ||
(yield execute_1.execute(checkGitStatus, `${action.workspace}/${temporaryDeploymentDirectory}`, true // This output is always silenced due to the large output it creates.
));
if (!hasFilesToCommit) {
if ((!action.singleCommit && !hasFilesToCommit) ||
// Ignores the case where single commit is true with a target folder to prevent incorrect early exiting.
(action.singleCommit && !action.targetFolder && !hasFilesToCommit)) {
return constants_1.Status.SKIPPED;
}
// Commits to GitHub.
Expand All @@ -134,6 +136,11 @@ function deploy(action) {
finally {
// Cleans up temporary files/folders and restores the git state.
core_1.info('Running post deployment cleanup jobs… 🗑️');
if (!action.singleCommit) {
core_1.info(`Resetting branch and removing artifacts…`);
yield execute_1.execute(`git checkout -B ${temporaryDeploymentBranch}`, `${action.workspace}/${temporaryDeploymentDirectory}`, action.silent);
yield execute_1.execute(`git branch -D ${action.branch} --force`, action.workspace, action.silent);
}
yield execute_1.execute(`git worktree remove ${temporaryDeploymentDirectory} --force`, action.workspace, action.silent);
yield io_1.rmRF(temporaryDeploymentDirectory);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionInterface } from './constants';
export declare const isNullOrUndefined: (value: any) => boolean;
export declare const isNullOrUndefined: (value: unknown) => boolean;
export declare const generateTokenType: (action: ActionInterface) => string;
export declare const generateRepositoryPath: (action: ActionInterface) => string;
export declare const generateFolderPath: (action: ActionInterface) => string;
Expand Down
2 changes: 1 addition & 1 deletion lib/worktree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export declare class GitCheckout {
constructor(branch: string);
toString(): string;
}
export declare function generateWorktree(action: ActionInterface, worktreedir: string, branchExists: boolean): Promise<void>;
export declare function generateWorktree(action: ActionInterface, worktreedir: string, branchExists: unknown): Promise<void>;
57 changes: 56 additions & 1 deletion node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@actions/core/lib/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/core.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/@actions/io/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions node_modules/@actions/io/lib/io-util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc8c70c

Please sign in to comment.