Skip to content

Commit

Permalink
Merge branch 'releases/v4-worktree' of https://github.com/JamesIves/g…
Browse files Browse the repository at this point in the history
…ithub-pages-deploy-action into releases/v4-worktree
  • Loading branch information
JamesIves committed May 17, 2024
2 parents 5390396 + b86d161 commit 8a308cc
Show file tree
Hide file tree
Showing 4,848 changed files with 1,457,392 additions and 2 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
node_modules
# node_moduless

# Test Temp Files
assets/.nojekyll
assets/CNAME

# Build
lib
# lib

## Registry
package-lock.json
Expand Down
96 changes: 96 additions & 0 deletions lib/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
export declare enum TestFlag {
NONE = 0,
HAS_CHANGED_FILES = 2,// Assume changes to commit.
HAS_REMOTE_BRANCH = 4,// Assume remote repository has existing commits.
UNABLE_TO_REMOVE_ORIGIN = 8,// Assume we can't remove origin.
UNABLE_TO_UNSET_GIT_CONFIG = 16,// Assume we can't remove previously set git configs.
HAS_REJECTED_COMMIT = 32
}
export interface ActionInterface {
/** The branch that the action should deploy to. */
branch: string;
/** git push with --dry-run */
dryRun?: boolean | null;
/** 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?: boolean | null;
/** If you need to use CLEAN but you'd like to preserve certain files or folders you can use this option. */
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. */
folder: string;
/** The auto generated folder path. */
folderPath?: string;
/** Whether to force-push or attempt to merge existing changes. */
force?: boolean;
/** Determines test scenarios the action is running in. */
isTest: TestFlag;
/** The git config name. */
name?: string;
/** The repository path, for example JamesIves/github-pages-deploy-action. */
repositoryName?: string;
/** The fully qualified repository path, this gets auto generated if repositoryName is provided. */
repositoryPath?: string;
/** Wipes the commit history from the deployment branch in favor of a single commit. */
singleCommit?: boolean | null;
/** Determines if the action should run in silent mode or not. */
silent: boolean;
/** Defines an SSH private key that can be used during deployment. This can also be set to true to use SSH deployment endpoints if you've already configured the SSH client outside of this package. */
sshKey?: string | boolean | null;
/** If you'd like to push the contents of the deployment folder into a specific directory on the deployment branch you can specify it here. */
targetFolder?: string;
/** Deployment token. */
token?: string | null;
/** The token type, ie ssh/token, this gets automatically generated. */
tokenType?: string;
/** The folder where your deployment project lives. */
workspace: string;
/** GitHub tag name */
tag?: string | null;
}
/** The minimum required values to run the action as a node module. */
export interface NodeActionInterface {
/** The branch that the action should deploy to. */
branch?: string;
/** The folder to deploy. */
folder: string;
/** The repository path, for example JamesIves/github-pages-deploy-action. */
repositoryName: string;
/** GitHub deployment token. */
token?: string | null;
/** Determines if the action should run in silent mode or not. */
silent: boolean;
/** Defines an SSH private key that can be used during deployment. This can also be set to true to use SSH deployment endpoints if you've already configured the SSH client outside of this package. */
sshKey?: string | boolean | null;
/** The folder where your deployment project lives. */
workspace: string;
/** Determines test scenarios the action is running in. */
isTest: TestFlag;
}
export declare const action: ActionInterface;
/** Types for the required action parameters. */
export type RequiredActionParameters = Pick<ActionInterface, 'token' | 'sshKey' | 'branch' | 'folder' | 'isTest'>;
/** Status codes for the action. */
export declare enum Status {
SUCCESS = "success",
FAILED = "failed",
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"
}
122 changes: 122 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
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");
const { pusher, repository } = github.context.payload;
/* Flags to signal different scenarios to test cases */
var TestFlag;
(function (TestFlag) {
TestFlag[TestFlag["NONE"] = 0] = "NONE";
TestFlag[TestFlag["HAS_CHANGED_FILES"] = 2] = "HAS_CHANGED_FILES";
TestFlag[TestFlag["HAS_REMOTE_BRANCH"] = 4] = "HAS_REMOTE_BRANCH";
TestFlag[TestFlag["UNABLE_TO_REMOVE_ORIGIN"] = 8] = "UNABLE_TO_REMOVE_ORIGIN";
TestFlag[TestFlag["UNABLE_TO_UNSET_GIT_CONFIG"] = 16] = "UNABLE_TO_UNSET_GIT_CONFIG";
TestFlag[TestFlag["HAS_REJECTED_COMMIT"] = 32] = "HAS_REJECTED_COMMIT"; // Assume commit rejection.
})(TestFlag || (exports.TestFlag = TestFlag = {}));
/* Required action data that gets initialized when running within the GitHub Actions environment. */
exports.action = {
folder: (0, core_1.getInput)('folder'),
branch: (0, core_1.getInput)('branch'),
commitMessage: (0, core_1.getInput)('commit-message'),
dryRun: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('dry-run'))
? (0, core_1.getInput)('dry-run').toLowerCase() === 'true'
: false,
force: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('force'))
? (0, core_1.getInput)('force').toLowerCase() === 'true'
: true,
clean: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('clean'))
? (0, core_1.getInput)('clean').toLowerCase() === 'true'
: false,
cleanExclude: ((0, core_1.getInput)('clean-exclude') || '')
.split('\n')
.filter(l => l !== ''),
hostname: process.env.GITHUB_SERVER_URL
? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL)
: 'github.com',
isTest: TestFlag.NONE,
email: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-email'))
? (0, core_1.getInput)('git-config-email')
: pusher && pusher.email
? pusher.email
: `${process.env.GITHUB_ACTOR || 'github-pages-deploy-action'}@users.noreply.${process.env.GITHUB_SERVER_URL
? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL)
: 'github.com'}`,
name: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-name'))
? (0, core_1.getInput)('git-config-name')
: pusher && pusher.name
? pusher.name
: process.env.GITHUB_ACTOR
? process.env.GITHUB_ACTOR
: 'GitHub Pages Deploy Action',
repositoryName: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('repository-name'))
? (0, core_1.getInput)('repository-name')
: repository && repository.full_name
? repository.full_name
: process.env.GITHUB_REPOSITORY,
token: (0, core_1.getInput)('token'),
singleCommit: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('single-commit'))
? (0, core_1.getInput)('single-commit').toLowerCase() === 'true'
: false,
silent: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('silent'))
? (0, core_1.getInput)('silent').toLowerCase() === 'true'
: false,
sshKey: (0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key'))
? false
: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key')) &&
(0, core_1.getInput)('ssh-key').toLowerCase() === 'true'
? true
: (0, core_1.getInput)('ssh-key'),
targetFolder: (0, core_1.getInput)('target-folder'),
workspace: process.env.GITHUB_WORKSPACE || '',
tag: (0, core_1.getInput)('tag')
};
/** Status codes for the action. */
var Status;
(function (Status) {
Status["SUCCESS"] = "success";
Status["FAILED"] = "failed";
Status["SKIPPED"] = "skipped";
Status["RUNNING"] = "running";
})(Status || (exports.Status = Status = {}));
/* Platform codes. */
var OperatingSystems;
(function (OperatingSystems) {
OperatingSystems["LINUX"] = "Linux";
OperatingSystems["WINDOWS"] = "Windows";
OperatingSystems["MACOS"] = "macOS";
})(OperatingSystems || (exports.OperatingSystems = 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 = DefaultExcludedFiles = {}));
18 changes: 18 additions & 0 deletions lib/execute.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference types="node" />
type ExecuteOutput = {
stdout: string;
stderr: string;
};
/** Wrapper around the GitHub toolkit exec command which returns the output.
* Also allows you to easily toggle the current working directory.
*
* @param {string} cmd - The command to execute.
* @param {string} cwd - The current working directory.
* @param {boolean} silent - Determines if the in/out should be silenced or not.
* @param {boolean} ignoreReturnCode - Determines whether to throw an error
* on a non-zero exit status or to leave implementation up to the caller.
*/
export declare function execute(cmd: string, cwd: string, silent: boolean, ignoreReturnCode?: boolean): Promise<ExecuteOutput>;
export declare function stdout(data: Buffer | string): void;
export declare function stderr(data: Buffer | string): void;
export {};
58 changes: 58 additions & 0 deletions lib/execute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stderr = exports.stdout = exports.execute = void 0;
const exec_1 = require("@actions/exec");
const buffer_1 = __importDefault(require("buffer"));
const output = { stdout: '', stderr: '' };
/** Wrapper around the GitHub toolkit exec command which returns the output.
* Also allows you to easily toggle the current working directory.
*
* @param {string} cmd - The command to execute.
* @param {string} cwd - The current working directory.
* @param {boolean} silent - Determines if the in/out should be silenced or not.
* @param {boolean} ignoreReturnCode - Determines whether to throw an error
* on a non-zero exit status or to leave implementation up to the caller.
*/
function execute(cmd_1, cwd_1, silent_1) {
return __awaiter(this, arguments, void 0, function* (cmd, cwd, silent, ignoreReturnCode = false) {
output.stdout = '';
output.stderr = '';
yield (0, exec_1.exec)(cmd, [], {
// Silences the input unless the INPUT_DEBUG flag is set.
silent,
cwd,
listeners: { stdout, stderr },
ignoreReturnCode
});
return Promise.resolve(output);
});
}
exports.execute = execute;
function stdout(data) {
const dataString = data.toString().trim();
if (output.stdout.length + dataString.length <
buffer_1.default.constants.MAX_STRING_LENGTH) {
output.stdout += dataString;
}
}
exports.stdout = stdout;
function stderr(data) {
const dataString = data.toString().trim();
if (output.stderr.length + dataString.length <
buffer_1.default.constants.MAX_STRING_LENGTH) {
output.stderr += dataString;
}
}
exports.stderr = stderr;
9 changes: 9 additions & 0 deletions lib/git.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ActionInterface, Status } from './constants';
/**
* Initializes git in the workspace.
*/
export declare function init(action: ActionInterface): Promise<void | Error>;
/**
* Runs the necessary steps to make the deployment.
*/
export declare function deploy(action: ActionInterface): Promise<Status>;
Loading

0 comments on commit 8a308cc

Please sign in to comment.