Skip to content

Commit

Permalink
Deploy Production Code for Commit fd3cf89 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Jan 6, 2022
1 parent fd3cf89 commit 8991156
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 13 deletions.
13 changes: 13 additions & 0 deletions lib/constants.d.ts
Expand Up @@ -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"
}
19 changes: 18 additions & 1 deletion lib/constants.js
Expand Up @@ -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");
Expand Down Expand Up @@ -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 = {}));
11 changes: 6 additions & 5 deletions lib/git.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions lib/lib.js
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions lib/util.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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. */
Expand Down
6 changes: 4 additions & 2 deletions lib/worktree.js
Expand Up @@ -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);
Expand Down

0 comments on commit 8991156

Please sign in to comment.