2021-02-08 12:58:32 +08:00
|
|
|
"use strict";
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
|
|
}) : (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 = {};
|
2021-03-04 22:04:23 +08:00
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
2021-02-08 12:58:32 +08:00
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
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"; // Assume we can't remove previously set git configs.
|
|
|
|
})(TestFlag = exports.TestFlag || (exports.TestFlag = {}));
|
|
|
|
/* Required action data that gets initialized when running within the GitHub Actions environment. */
|
|
|
|
exports.action = {
|
2021-11-18 20:58:07 +08:00
|
|
|
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'
|
2021-02-08 12:58:32 +08:00
|
|
|
: false,
|
2021-11-18 20:58:07 +08:00
|
|
|
clean: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('clean'))
|
|
|
|
? (0, core_1.getInput)('clean').toLowerCase() === 'true'
|
2021-02-08 12:58:32 +08:00
|
|
|
: false,
|
2021-11-18 20:58:07 +08:00
|
|
|
cleanExclude: ((0, core_1.getInput)('clean-exclude') || '')
|
2021-02-08 12:58:32 +08:00
|
|
|
.split('\n')
|
|
|
|
.filter(l => l !== ''),
|
2021-03-04 22:04:23 +08:00
|
|
|
hostname: process.env.GITHUB_SERVER_URL
|
2021-11-18 20:58:07 +08:00
|
|
|
? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL)
|
2021-03-04 22:04:23 +08:00
|
|
|
: 'github.com',
|
2021-02-08 12:58:32 +08:00
|
|
|
isTest: TestFlag.NONE,
|
2021-11-18 20:58:07 +08:00
|
|
|
email: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-email'), true)
|
|
|
|
? (0, core_1.getInput)('git-config-email')
|
2021-02-08 12:58:32 +08:00
|
|
|
: pusher && pusher.email
|
|
|
|
? pusher.email
|
2021-03-04 22:04:23 +08:00
|
|
|
: `${process.env.GITHUB_ACTOR || 'github-pages-deploy-action'}@users.noreply.${process.env.GITHUB_SERVER_URL
|
2021-11-18 20:58:07 +08:00
|
|
|
? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL)
|
2021-03-04 22:04:23 +08:00
|
|
|
: 'github.com'}`,
|
2021-11-18 20:58:07 +08:00
|
|
|
name: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-name'))
|
|
|
|
? (0, core_1.getInput)('git-config-name')
|
2021-02-08 12:58:32 +08:00
|
|
|
: pusher && pusher.name
|
|
|
|
? pusher.name
|
|
|
|
: process.env.GITHUB_ACTOR
|
|
|
|
? process.env.GITHUB_ACTOR
|
|
|
|
: 'GitHub Pages Deploy Action',
|
2021-11-18 20:58:07 +08:00
|
|
|
repositoryName: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('repository-name'))
|
|
|
|
? (0, core_1.getInput)('repository-name')
|
2021-02-08 12:58:32 +08:00
|
|
|
: repository && repository.full_name
|
|
|
|
? repository.full_name
|
|
|
|
: process.env.GITHUB_REPOSITORY,
|
2021-11-18 20:58:07 +08:00
|
|
|
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'
|
2021-02-08 12:58:32 +08:00
|
|
|
: false,
|
2021-11-18 20:58:07 +08:00
|
|
|
silent: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('silent'))
|
|
|
|
? (0, core_1.getInput)('silent').toLowerCase() === 'true'
|
2021-02-08 12:58:32 +08:00
|
|
|
: false,
|
2021-11-18 20:58:07 +08:00
|
|
|
sshKey: (0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key'))
|
2021-02-08 12:58:32 +08:00
|
|
|
? false
|
2021-11-18 20:58:07 +08:00
|
|
|
: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key')) &&
|
|
|
|
(0, core_1.getInput)('ssh-key').toLowerCase() === 'true'
|
2021-02-08 12:58:32 +08:00
|
|
|
? true
|
2021-11-18 20:58:07 +08:00
|
|
|
: (0, core_1.getInput)('ssh-key'),
|
|
|
|
targetFolder: (0, core_1.getInput)('target-folder'),
|
2021-02-08 12:58:32 +08:00
|
|
|
workspace: process.env.GITHUB_WORKSPACE || ''
|
|
|
|
};
|
|
|
|
/** Status codes for the action. */
|
|
|
|
var Status;
|
|
|
|
(function (Status) {
|
|
|
|
Status["SUCCESS"] = "success";
|
|
|
|
Status["FAILED"] = "failed";
|
|
|
|
Status["SKIPPED"] = "skipped";
|
|
|
|
Status["RUNNING"] = "running";
|
|
|
|
})(Status = exports.Status || (exports.Status = {}));
|