From 89911566f979b4e138ac82c96c9b2aa7ea97759b Mon Sep 17 00:00:00 2001 From: James Ives Date: Thu, 6 Jan 2022 15:14:12 +0000 Subject: [PATCH] =?UTF-8?q?Deploy=20Production=20Code=20for=20Commit=20fd3?= =?UTF-8?q?cf89aa3eb0cbd9a763f7c74106571ffaccb72=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants.d.ts | 13 +++++++++++++ lib/constants.js | 19 ++++++++++++++++++- lib/git.js | 11 ++++++----- lib/lib.js | 10 +++++----- lib/util.js | 4 ++++ lib/worktree.js | 6 ++++-- 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/lib/constants.d.ts b/lib/constants.d.ts index 4329df5d2..776e63f56 100644 --- a/lib/constants.d.ts +++ b/lib/constants.d.ts @@ -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" +} diff --git a/lib/constants.js b/lib/constants.js index 5b3ed9f7e..d81844f7b 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -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 = {})); diff --git a/lib/git.js b/lib/git.js index 514d19765..39e11c561 100644 --- a/lib/git.js +++ b/lib/git.js @@ -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) { diff --git a/lib/lib.js b/lib/lib.js index 247fb778f..dcb5a2ea3 100644 --- a/lib/lib.js +++ b/lib/lib.js @@ -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. diff --git a/lib/util.js b/lib/util.js index 5c08dafe8..0d77c0f46 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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. */ diff --git a/lib/worktree.js b/lib/worktree.js index e757aedb0..db5bf1a62 100644 --- a/lib/worktree.js +++ b/lib/worktree.js @@ -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);