Skip to content

Commit

Permalink
Deploy Production Code for Commit 45f4c85 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Mar 4, 2021
1 parent 45f4c85 commit 0ac8f9e
Show file tree
Hide file tree
Showing 60 changed files with 403 additions and 175 deletions.
2 changes: 2 additions & 0 deletions lib/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface ActionInterface {
cleanExclude?: string[];
/** If you need to customize the commit message for an integration you can do so. */
commitMessage?: string;
/** The hostname of which the GitHub Workflow is being run on, ie: github.com */
hostname?: string;
/** The git config email. */
email?: string;
/** The folder to deploy. */
Expand Down
9 changes: 7 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -47,12 +47,17 @@ exports.action = {
cleanExclude: (core_1.getInput('clean-exclude') || '')
.split('\n')
.filter(l => l !== ''),
hostname: process.env.GITHUB_SERVER_URL
? util_1.stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
: 'github.com',
isTest: TestFlag.NONE,
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`,
: `${process.env.GITHUB_ACTOR || 'github-pages-deploy-action'}@users.noreply.${process.env.GITHUB_SERVER_URL
? util_1.stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
: 'github.com'}`,
name: !util_1.isNullOrUndefined(core_1.getInput('git-config-name'))
? core_1.getInput('git-config-name')
: pusher && pusher.name
Expand Down
2 changes: 1 addition & 1 deletion lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function init(action) {
/* Ensures that previously set Git configs do not interfere with the deployment.
Only runs in the GitHub Actions CI environment if a user is not using an SSH key.
*/
yield execute_1.execute(`git config --local --unset-all http.https://github.com/.extraheader`, action.workspace, action.silent);
yield execute_1.execute(`git config --local --unset-all http.https://${action.hostname}/.extraheader`, action.workspace, action.silent);
}
if (action.isTest === constants_1.TestFlag.UNABLE_TO_UNSET_GIT_CONFIG) {
throw new Error();
Expand Down
4 changes: 2 additions & 2 deletions lib/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function configureSSH(action) {
const sshDirectory = `${process.env['HOME']}/.ssh`;
const sshKnownHostsDirectory = `${sshDirectory}/known_hosts`;
// SSH fingerprints provided by GitHub: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/githubs-ssh-key-fingerprints
const sshGitHubKnownHostRsa = '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n';
const sshGitHubKnownHostDss = '\ngithub.com ssh-dss AAAAB3NzaC1kc3MAAACBANGFW2P9xlGU3zWrymJgI/lKo//ZW2WfVtmbsUZJ5uyKArtlQOT2+WRhcg4979aFxgKdcsqA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OHf6s6ITcZvjvdbp6ZbpM+DuJT7Bw+h5Fx8Qt8I16oCZYmAPJRtu46o9C2zk1AAAAFQC4gdFGcSbp5Gr0Wd5Ay/jtcldMewAAAIATTgn4sY4Nem/FQE+XJlyUQptPWMem5fwOcWtSXiTKaaN0lkk2p2snz+EJvAGXGq9dTSWHyLJSM2W6ZdQDqWJ1k+cL8CARAqL+UMwF84CR0m3hj+wtVGD/J4G5kW2DBAf4/bqzP4469lT+dF2FRQ2L9JKXrCWcnhMtJUvua8dvnwAAAIB6C4nQfAA7x8oLta6tT+oCk2WQcydNsyugE8vLrHlogoWEicla6cWPk7oXSspbzUcfkjN3Qa6e74PhRkc7JdSdAlFzU3m7LMkXo1MHgkqNX8glxWNVqBSc0YRdbFdTkL0C6gtpklilhvuHQCdbgB3LBAikcRkDp+FCVkUgPC/7Rw==\n`;
core_1.info(`Configuring SSH client… 🔑`);
yield io_1.mkdirP(sshDirectory);
fs_1.appendFileSync(sshKnownHostsDirectory, sshGitHubKnownHostRsa);
Expand Down
2 changes: 2 additions & 0 deletions lib/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export declare const generateRepositoryPath: (action: ActionInterface) => string
export declare const generateFolderPath: (action: ActionInterface) => string;
export declare const checkParameters: (action: ActionInterface) => void;
export declare const suppressSensitiveInformation: (str: string, action: ActionInterface) => string;
/** Strips the protocol from a provided URL. */
export declare const stripProtocolFromUrl: (url: string) => string;
27 changes: 18 additions & 9 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.suppressSensitiveInformation = exports.checkParameters = exports.generateFolderPath = exports.generateRepositoryPath = exports.generateTokenType = exports.isNullOrUndefined = void 0;
exports.stripProtocolFromUrl = exports.suppressSensitiveInformation = exports.checkParameters = exports.generateFolderPath = exports.generateRepositoryPath = exports.generateTokenType = exports.isNullOrUndefined = void 0;
const core_1 = require("@actions/core");
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
/* Replaces all instances of a match in a string. */
const replaceAll = (input, find, replace) => input.split(find).join(replace);
/* Utility function that checks to see if a value is undefined or not. */
exports.isNullOrUndefined = (value) => typeof value === 'undefined' || value === null || value === '';
const isNullOrUndefined = (value) => typeof value === 'undefined' || value === null || value === '';
exports.isNullOrUndefined = isNullOrUndefined;
/* Generates a token type used for the action. */
exports.generateTokenType = (action) => action.sshKey ? 'SSH Deploy Key' : action.token ? 'Deploy Token' : '…';
const generateTokenType = (action) => action.sshKey ? 'SSH Deploy Key' : action.token ? 'Deploy Token' : '…';
exports.generateTokenType = generateTokenType;
/* Generates a the repository path used to make the commits. */
exports.generateRepositoryPath = (action) => action.sshKey
? `git@github.com:${action.repositoryName}`
: `https://${`x-access-token:${action.token}`}@github.com/${action.repositoryName}.git`;
const generateRepositoryPath = (action) => action.sshKey
? `git@${action.hostname}:${action.repositoryName}`
: `https://${`x-access-token:${action.token}`}@${action.hostname}/${action.repositoryName}.git`;
exports.generateRepositoryPath = generateRepositoryPath;
/* Genetate absolute folder path by the provided folder name */
exports.generateFolderPath = (action) => {
const generateFolderPath = (action) => {
const folderName = action['folder'];
return path_1.default.isAbsolute(folderName)
? folderName
: folderName.startsWith('~')
? folderName.replace('~', process.env.HOME)
: path_1.default.join(action.workspace, folderName);
};
exports.generateFolderPath = generateFolderPath;
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */
const hasRequiredParameters = (action, params) => {
const nonNullParams = params.filter(param => !exports.isNullOrUndefined(action[param]));
return Boolean(nonNullParams.length);
};
/* Verifies the action has the required parameters to run, otherwise throw an error. */
exports.checkParameters = (action) => {
const checkParameters = (action) => {
if (!hasRequiredParameters(action, ['token', 'sshKey'])) {
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.');
}
Expand All @@ -46,8 +50,9 @@ exports.checkParameters = (action) => {
throw new Error(`The directory you're trying to deploy named ${action.folderPath} doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗`);
}
};
exports.checkParameters = checkParameters;
/* Suppresses sensitive information from being exposed in error messages. */
exports.suppressSensitiveInformation = (str, action) => {
const suppressSensitiveInformation = (str, action) => {
let value = str;
if (core_1.isDebug()) {
// Data is unmasked in debug mode.
Expand All @@ -59,3 +64,7 @@ exports.suppressSensitiveInformation = (str, action) => {
}
return value;
};
exports.suppressSensitiveInformation = suppressSensitiveInformation;
/** Strips the protocol from a provided URL. */
const stripProtocolFromUrl = (url) => url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0];
exports.stripProtocolFromUrl = stripProtocolFromUrl;
2 changes: 1 addition & 1 deletion node_modules/.bin/which

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

4 changes: 2 additions & 2 deletions node_modules/@types/node/README.md

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

5 changes: 5 additions & 0 deletions node_modules/@types/node/assert.d.ts

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

9 changes: 8 additions & 1 deletion node_modules/@types/node/async_hooks.d.ts

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

6 changes: 5 additions & 1 deletion node_modules/@types/node/buffer.d.ts

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

14 changes: 9 additions & 5 deletions node_modules/@types/node/child_process.d.ts

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

16 changes: 10 additions & 6 deletions node_modules/@types/node/cluster.d.ts

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

8 changes: 6 additions & 2 deletions node_modules/@types/node/console.d.ts

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

21 changes: 16 additions & 5 deletions node_modules/@types/node/constants.d.ts

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

6 changes: 5 additions & 1 deletion node_modules/@types/node/crypto.d.ts

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

Loading

0 comments on commit 0ac8f9e

Please sign in to comment.