Deploy Production Code for Commit fd3cf89aa3 🚀

This commit is contained in:
James Ives 2022-01-06 15:14:12 +00:00
parent fd3cf89aa3
commit 89911566f9
6 changed files with 50 additions and 13 deletions

13
lib/constants.d.ts vendored
View File

@ -76,3 +76,16 @@ export declare enum Status {
SKIPPED = "skipped",
RUNNING = "running"
}
export declare enum OperatingSystems {
LINUX = "Linux",
WINDOWS = "Windows",
MACOS = "macOS"
}
export declare const SupportedOperatingSystems: OperatingSystems[];
export declare enum DefaultExcludedFiles {
CNAME = "CNAME",
NOJEKYLL = ".nojekyll",
SSH = ".ssh",
GIT = ".git",
GITHUB = ".github"
}

View File

@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Status = exports.action = exports.TestFlag = void 0;
exports.DefaultExcludedFiles = exports.SupportedOperatingSystems = exports.OperatingSystems = exports.Status = exports.action = exports.TestFlag = void 0;
const core_1 = require("@actions/core");
const github = __importStar(require("@actions/github"));
const util_1 = require("./util");
@ -94,3 +94,20 @@ var Status;
Status["SKIPPED"] = "skipped";
Status["RUNNING"] = "running";
})(Status = exports.Status || (exports.Status = {}));
/* Platform codes. */
var OperatingSystems;
(function (OperatingSystems) {
OperatingSystems["LINUX"] = "Linux";
OperatingSystems["WINDOWS"] = "Windows";
OperatingSystems["MACOS"] = "macOS";
})(OperatingSystems = exports.OperatingSystems || (exports.OperatingSystems = {}));
exports.SupportedOperatingSystems = [OperatingSystems.LINUX];
/* Excluded files. */
var DefaultExcludedFiles;
(function (DefaultExcludedFiles) {
DefaultExcludedFiles["CNAME"] = "CNAME";
DefaultExcludedFiles["NOJEKYLL"] = ".nojekyll";
DefaultExcludedFiles["SSH"] = ".ssh";
DefaultExcludedFiles["GIT"] = ".git";
DefaultExcludedFiles["GITHUB"] = ".github";
})(DefaultExcludedFiles = exports.DefaultExcludedFiles || (exports.DefaultExcludedFiles = {}));

View File

@ -28,6 +28,7 @@ function init(action) {
(0, core_1.info)('Configuring git…');
yield (0, execute_1.execute)(`git config user.name "${action.name}"`, action.workspace, action.silent);
yield (0, execute_1.execute)(`git config user.email "${action.email}"`, action.workspace, action.silent);
yield (0, execute_1.execute)(`git config core.ignorecase false`, action.workspace, action.silent);
try {
if ((process.env.CI && !action.sshKey) || action.isTest) {
/* Ensures that previously set Git configs do not interfere with the deployment.
@ -96,12 +97,12 @@ function deploy(action) {
yield (0, execute_1.execute)(`rsync -q -av --checksum --progress ${action.folderPath}/. ${action.targetFolder
? `${temporaryDeploymentDirectory}/${action.targetFolder}`
: temporaryDeploymentDirectory} ${action.clean
? `--delete ${excludes} ${!fs_1.default.existsSync(`${action.folderPath}/CNAME`)
? '--exclude CNAME'
: ''} ${!fs_1.default.existsSync(`${action.folderPath}/.nojekyll`)
? '--exclude .nojekyll'
? `--delete ${excludes} ${!fs_1.default.existsSync(`${action.folderPath}/${constants_1.DefaultExcludedFiles.CNAME}`)
? `--exclude ${constants_1.DefaultExcludedFiles.CNAME}`
: ''} ${!fs_1.default.existsSync(`${action.folderPath}/${constants_1.DefaultExcludedFiles.NOJEKYLL}`)
? `--exclude ${constants_1.DefaultExcludedFiles.NOJEKYLL}`
: ''}`
: ''} --exclude .ssh --exclude .git --exclude .github ${action.folderPath === action.workspace
: ''} --exclude ${constants_1.DefaultExcludedFiles.SSH} --exclude ${constants_1.DefaultExcludedFiles.GIT} --exclude ${constants_1.DefaultExcludedFiles.GITHUB} ${action.folderPath === action.workspace
? `--exclude ${temporaryDeploymentDirectory}`
: ''}`, action.workspace, action.silent);
if (action.singleCommit) {

View File

@ -25,12 +25,12 @@ function run(configuration) {
(0, core_1.info)(`
GitHub Pages Deploy Action 🚀
🚀 Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
💖 Support: https://github.com/sponsors/JamesIves
📣 Maintained by James Ives: https://jamesiv.es
💖 Support: https://github.com/sponsors/JamesIves`);
🚀 Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action
Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues`);
(0, core_1.info)('Checking configuration and starting deployment… 🚦');
const settings = Object.assign({}, configuration);
// Defines the repository/folder paths and token types.

View File

@ -7,6 +7,7 @@ exports.stripProtocolFromUrl = exports.extractErrorMessage = exports.suppressSen
const core_1 = require("@actions/core");
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
const constants_1 = require("./constants");
/* 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.
@ -50,6 +51,9 @@ const checkParameters = (action) => {
if (!(0, fs_1.existsSync)(action.folderPath)) {
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. ❗`);
}
if (constants_1.SupportedOperatingSystems.includes(process.env.RUNNER_OS)) {
(0, core_1.info)(`The operating system you're using is not supported and results may be varied. Please refer to the documentation for more details. ❗`);
}
};
exports.checkParameters = checkParameters;
/* Suppresses sensitive information from being exposed in error messages. */

View File

@ -44,8 +44,10 @@ function generateWorktree(action, worktreedir, branchExists) {
// There's existing data on the branch to check out
checkout.commitish = `origin/${action.branch}`;
}
if (!branchExists || action.singleCommit) {
// Create a new history if we don't have the branch, or if we want to reset it
if (!branchExists ||
(action.singleCommit && action.branch !== process.env.GITHUB_REF_NAME)) {
/* Create a new history if we don't have the branch, or if we want to reset it.
If the ref name is the same as the branch name, do not attempt to create an orphan of it. */
checkout.orphan = true;
}
yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent);