Skip to content

Commit

Permalink
Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Mar 7, 2020
1 parent b52d6c9 commit e0c5ab9
Show file tree
Hide file tree
Showing 11,775 changed files with 598,082 additions and 54,807 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 3 additions & 3 deletions lib/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface actionInterface {
export interface ActionInterface {
/** Deployment access token. */
accessToken?: string | null;
/** The base branch that the deploy should be made from. */
Expand All @@ -8,7 +8,7 @@ export interface actionInterface {
/** If your project generates hashed files on build you can use this option to automatically delete them from the deployment branch with each deploy. This option can be toggled on by setting it to true. */
clean?: string | boolean;
/** If you need to use CLEAN but you'd like to preserve certain files or folders you can use this option. */
cleanExclude?: string | Array<string>;
cleanExclude?: string | string[];
/** If you need to customize the commit message for an integration you can do so. */
commitMessage?: string;
/** Unhides the Git commands from the function terminal. */
Expand Down Expand Up @@ -40,4 +40,4 @@ export interface actionInterface {
/** The folder where your deployment project lives. */
workspace: string;
}
export declare const action: actionInterface;
export declare const action: ActionInterface;
44 changes: 22 additions & 22 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ const util_1 = require("./util");
const { pusher, repository } = github.context.payload;
/* Required action data that gets initialized when running within the GitHub Actions environment. */
exports.action = {
accessToken: core_1.getInput("ACCESS_TOKEN"),
baseBranch: core_1.getInput("BASE_BRANCH"),
folder: core_1.getInput("FOLDER"),
branch: core_1.getInput("BRANCH"),
commitMessage: core_1.getInput("COMMIT_MESSAGE"),
clean: core_1.getInput("CLEAN"),
cleanExclude: core_1.getInput("CLEAN_EXCLUDE"),
debug: core_1.getInput("DEBUG"),
defaultBranch: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : "master",
accessToken: core_1.getInput('ACCESS_TOKEN'),
baseBranch: core_1.getInput('BASE_BRANCH'),
folder: core_1.getInput('FOLDER'),
branch: core_1.getInput('BRANCH'),
commitMessage: core_1.getInput('COMMIT_MESSAGE'),
clean: core_1.getInput('CLEAN'),
cleanExclude: core_1.getInput('CLEAN_EXCLUDE'),
debug: core_1.getInput('DEBUG'),
defaultBranch: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : 'master',
isTest: process.env.UNIT_TEST,
ssh: core_1.getInput("SSH"),
email: !util_1.isNullOrUndefined(core_1.getInput("GIT_CONFIG_EMAIL"))
? core_1.getInput("GIT_CONFIG_EMAIL")
ssh: core_1.getInput('SSH'),
email: !util_1.isNullOrUndefined(core_1.getInput('GIT_CONFIG_EMAIL'))
? core_1.getInput('GIT_CONFIG_EMAIL')
: pusher && pusher.email
? pusher.email
: `${process.env.GITHUB_ACTOR ||
"github-pages-deploy-action"}@users.noreply.github.com`,
gitHubToken: core_1.getInput("GITHUB_TOKEN"),
name: !util_1.isNullOrUndefined(core_1.getInput("GIT_CONFIG_NAME"))
? core_1.getInput("GIT_CONFIG_NAME")
'github-pages-deploy-action'}@users.noreply.github.com`,
gitHubToken: core_1.getInput('GITHUB_TOKEN'),
name: !util_1.isNullOrUndefined(core_1.getInput('GIT_CONFIG_NAME'))
? core_1.getInput('GIT_CONFIG_NAME')
: pusher && pusher.name
? pusher.name
: process.env.GITHUB_ACTOR
? process.env.GITHUB_ACTOR
: "GitHub Pages Deploy Action",
repositoryName: !util_1.isNullOrUndefined(core_1.getInput("REPOSITORY_NAME"))
? core_1.getInput("REPOSITORY_NAME")
: 'GitHub Pages Deploy Action',
repositoryName: !util_1.isNullOrUndefined(core_1.getInput('REPOSITORY_NAME'))
? core_1.getInput('REPOSITORY_NAME')
: repository && repository.full_name
? repository.full_name
: process.env.GITHUB_REPOSITORY,
root: ".",
targetFolder: core_1.getInput("TARGET_FOLDER"),
workspace: process.env.GITHUB_WORKSPACE || ""
root: '.',
targetFolder: core_1.getInput('TARGET_FOLDER'),
workspace: process.env.GITHUB_WORKSPACE || ''
};
2 changes: 1 addition & 1 deletion lib/execute.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* @returns - The output from the command.
*/
export declare function execute(cmd: string, cwd: string): Promise<any>;
export declare function stdout(data: any): void;
export declare function stdout(data: any): string | void;
2 changes: 1 addition & 1 deletion lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let output;
*/
function execute(cmd, cwd) {
return __awaiter(this, void 0, void 0, function* () {
output = "";
output = '';
yield exec_1.exec(cmd, [], {
// Silences the input unless the INPUT_DEBUG flag is set.
silent: process.env.DEBUG_DEPLOY_ACTION ? false : true,
Expand Down
10 changes: 5 additions & 5 deletions lib/git.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { actionInterface } from "./constants";
export declare function init(action: actionInterface): Promise<void | Error>;
export declare function switchToBaseBranch(action: actionInterface): Promise<void>;
export declare function generateBranch(action: actionInterface): Promise<void>;
export declare function deploy(action: actionInterface): Promise<void>;
import { ActionInterface } from './constants';
export declare function init(action: ActionInterface): Promise<void | Error>;
export declare function switchToBaseBranch(action: ActionInterface): Promise<void>;
export declare function generateBranch(action: ActionInterface): Promise<void>;
export declare function deploy(action: ActionInterface): Promise<void>;
30 changes: 16 additions & 14 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ function init(action) {
try {
util_1.hasRequiredParameters(action);
console.log(`Deploying using ${action.tokenType}... 🔑`);
console.log("Configuring git...");
console.log('Configuring git...');
yield execute_1.execute(`git init`, action.workspace);
yield execute_1.execute(`git config user.name "${action.name}"`, action.workspace);
yield execute_1.execute(`git config user.email "${action.email}"`, action.workspace);
yield execute_1.execute(`git remote rm origin`, action.workspace);
yield execute_1.execute(`git remote add origin ${action.repositoryPath}`, action.workspace);
yield execute_1.execute(`git fetch`, action.workspace);
console.log("Git configured... 🔧");
console.log('Git configured... 🔧');
}
catch (error) {
throw new Error(`There was an error initializing the repository: ${util_1.suppressSensitiveInformation(error.message, action)} ❌`);
Expand Down Expand Up @@ -68,9 +68,9 @@ exports.generateBranch = generateBranch;
/* Runs the necessary steps to make the deployment. */
function deploy(action) {
return __awaiter(this, void 0, void 0, function* () {
const temporaryDeploymentDirectory = "gh-action-temp-deployment-folder";
const temporaryDeploymentBranch = "gh-action-temp-deployment-branch";
console.log("Starting to commit changes...");
const temporaryDeploymentDirectory = 'gh-action-temp-deployment-folder';
const temporaryDeploymentBranch = 'gh-action-temp-deployment-branch';
console.log('Starting to commit changes...');
try {
util_1.hasRequiredParameters(action);
/*
Expand All @@ -86,16 +86,18 @@ function deploy(action) {
yield execute_1.execute(`git fetch ${action.repositoryPath}`, action.workspace);
yield execute_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`, action.workspace);
// Ensures that items that need to be excluded from the clean job get parsed.
let excludes = "";
let excludes = '';
if (action.clean && action.cleanExclude) {
try {
const excludedItems = typeof action.cleanExclude === "string"
const excludedItems = typeof action.cleanExclude === 'string'
? JSON.parse(action.cleanExclude)
: action.cleanExclude;
excludedItems.forEach((item) => (excludes += `--exclude ${item} `));
for (const item of excludedItems) {
excludes += `--exclude ${item} `;
}
}
catch (_a) {
console.log("There was an error parsing your CLEAN_EXCLUDE items. Please refer to the README for more details. ❌");
console.log('There was an error parsing your CLEAN_EXCLUDE items. Please refer to the README for more details. ❌');
}
}
/*
Expand All @@ -106,24 +108,24 @@ function deploy(action) {
? `${temporaryDeploymentDirectory}/${action.targetFolder}`
: temporaryDeploymentDirectory} ${action.clean
? `--delete ${excludes} --exclude CNAME --exclude .nojekyll`
: ""} --exclude .ssh --exclude .git --exclude .github ${action.folder === action.root
: ''} --exclude .ssh --exclude .git --exclude .github ${action.folder === action.root
? `--exclude ${temporaryDeploymentDirectory}`
: ""}`, action.workspace);
: ''}`, action.workspace);
const hasFilesToCommit = yield execute_1.execute(`git status --porcelain`, `${action.workspace}/${temporaryDeploymentDirectory}`);
if (!hasFilesToCommit && !action.isTest) {
console.log("There is nothing to commit. Exiting early... 📭");
console.log('There is nothing to commit. Exiting early... 📭');
return;
}
// Commits to GitHub.
yield execute_1.execute(`git add --all .`, `${action.workspace}/${temporaryDeploymentDirectory}`);
yield execute_1.execute(`git checkout -b ${temporaryDeploymentBranch}`, `${action.workspace}/${temporaryDeploymentDirectory}`);
yield execute_1.execute(`git commit -m "${!util_1.isNullOrUndefined(action.commitMessage)
? action.commitMessage
: `Deploying to ${action.branch} from ${action.baseBranch}`} ${process.env.GITHUB_SHA ? `- ${process.env.GITHUB_SHA}` : ""} 🚀" --quiet`, `${action.workspace}/${temporaryDeploymentDirectory}`);
: `Deploying to ${action.branch} from ${action.baseBranch}`} ${process.env.GITHUB_SHA ? `- ${process.env.GITHUB_SHA}` : ''} 🚀" --quiet`, `${action.workspace}/${temporaryDeploymentDirectory}`);
yield execute_1.execute(`git push --force ${action.repositoryPath} ${temporaryDeploymentBranch}:${action.branch}`, `${action.workspace}/${temporaryDeploymentDirectory}`);
console.log(`Changes committed to the ${action.branch} branch... 📦`);
// Cleans up temporary files/folders and restores the git state.
console.log("Running post deployment cleanup jobs...");
console.log('Running post deployment cleanup jobs...');
yield execute_1.execute(`git checkout --progress --force ${action.defaultBranch}`, action.workspace);
}
catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions lib/lib.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { actionInterface } from "./constants";
import { deploy, generateBranch, init } from "./git";
import { ActionInterface } from './constants';
import { deploy, generateBranch, init } from './git';
/** Initializes and runs the action. */
export default function run(configuration: actionInterface): Promise<void>;
export { init, deploy, generateBranch, actionInterface };
export default function run(configuration: ActionInterface): Promise<void>;
export { init, deploy, generateBranch, ActionInterface };
8 changes: 4 additions & 4 deletions lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ function run(configuration) {
return __awaiter(this, void 0, void 0, function* () {
let errorState = false;
try {
console.log("Checking configuration and starting deployment...🚦");
console.log('Checking configuration and starting deployment...🚦');
const settings = Object.assign(Object.assign({}, constants_1.action), configuration);
// Defines the repository paths and token types.
settings.repositoryPath = util_1.generateRepositoryPath(settings);
settings.tokenType = util_1.generateTokenType(settings);
if (settings.debug) {
// Sets the debug flag if passed as an arguement.
core_1.exportVariable("DEBUG_DEPLOY_ACTION", "debug");
core_1.exportVariable('DEBUG_DEPLOY_ACTION', 'debug');
}
yield git_1.init(settings);
yield git_1.deploy(settings);
Expand All @@ -39,8 +39,8 @@ function run(configuration) {
}
finally {
console.log(`${errorState
? "Deployment Failed ❌"
: "Completed Deployment Successfully! ✅"}`);
? 'Deployment Failed ❌'
: 'Completed Deployment Successfully! ✅'}`);
}
});
}
Expand Down
10 changes: 5 additions & 5 deletions lib/util.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { actionInterface } from "./constants";
import { ActionInterface } from './constants';
export declare const isNullOrUndefined: (value: any) => boolean;
export declare const generateTokenType: (action: actionInterface) => string;
export declare const generateRepositoryPath: (action: actionInterface) => string;
export declare const hasRequiredParameters: (action: actionInterface) => void;
export declare const suppressSensitiveInformation: (str: string, action: actionInterface) => string;
export declare const generateTokenType: (action: ActionInterface) => string;
export declare const generateRepositoryPath: (action: ActionInterface) => string;
export declare const hasRequiredParameters: (action: ActionInterface) => void;
export declare const suppressSensitiveInformation: (str: string, action: ActionInterface) => string;
26 changes: 13 additions & 13 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@actions/core");
/* Utility function that checks to see if a value is undefined or not. */
exports.isNullOrUndefined = (value) => typeof value === "undefined" || value === null || value === "";
exports.isNullOrUndefined = (value) => typeof value === 'undefined' || value === null || value === '';
/* Generates a token type used for the action. */
exports.generateTokenType = (action) => action.ssh
? "SSH Deploy Key"
? 'SSH Deploy Key'
: action.accessToken
? "Access Token"
? 'Access Token'
: action.gitHubToken
? "GitHub Token"
: "...";
? 'GitHub Token'
: '...';
/* Generates a the repository path used to make the commits. */
exports.generateRepositoryPath = (action) => action.ssh
? `git@github.com:${action.repositoryName}`
Expand All @@ -22,33 +22,33 @@ exports.hasRequiredParameters = (action) => {
exports.isNullOrUndefined(action.gitHubToken) &&
exports.isNullOrUndefined(action.ssh)) ||
exports.isNullOrUndefined(action.repositoryPath)) {
throw new Error("No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.");
throw new Error('No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.');
}
if (exports.isNullOrUndefined(action.branch)) {
throw new Error("Branch is required.");
throw new Error('Branch is required.');
}
if (!action.folder || exports.isNullOrUndefined(action.folder)) {
throw new Error("You must provide the action with a folder to deploy.");
throw new Error('You must provide the action with a folder to deploy.');
}
if (action.folder.startsWith("/") || action.folder.startsWith("./")) {
if (action.folder.startsWith('/') || action.folder.startsWith('./')) {
throw new Error("Incorrectly formatted build folder. The deployment folder cannot be prefixed with '/' or './'. Instead reference the folder name directly.");
}
};
/* Suppresses sensitive information from being exposed in error messages. */
exports.suppressSensitiveInformation = (str, action) => {
let value = str;
if (core_1.getInput("DEBUG")) {
if (core_1.getInput('DEBUG')) {
// Data is unmasked in debug mode.
return value;
}
if (action.accessToken) {
value = value.replace(action.accessToken, "***");
value = value.replace(action.accessToken, '***');
}
if (action.gitHubToken) {
value = value.replace(action.gitHubToken, "***");
value = value.replace(action.gitHubToken, '***');
}
if (action.repositoryPath) {
value = value.replace(action.repositoryPath, "***");
value = value.replace(action.repositoryPath, '***');
}
return value;
};
1 change: 1 addition & 0 deletions node_modules/.bin/eslint

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/.bin/eslint-config-prettier-check

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/.bin/eslint-github-init

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/.bin/eslint-ignore-errors

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/.bin/eslint-unused-modules

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/.bin/flow-coverage

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/.bin/github-lint

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/.bin/loose-envify

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/.bin/npm-check-github-package-requirements

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/.bin/rimraf

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/.bin/semver

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

1 change: 0 additions & 1 deletion node_modules/.bin/tslint

This file was deleted.

Loading

0 comments on commit e0c5ab9

Please sign in to comment.