|
| 1 | +"use strict"; |
| 2 | +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
| 3 | + if (k2 === undefined) k2 = k; |
| 4 | + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); |
| 5 | +}) : (function(o, m, k, k2) { |
| 6 | + if (k2 === undefined) k2 = k; |
| 7 | + o[k2] = m[k]; |
| 8 | +})); |
| 9 | +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
| 10 | + Object.defineProperty(o, "default", { enumerable: true, value: v }); |
| 11 | +}) : function(o, v) { |
| 12 | + o["default"] = v; |
| 13 | +}); |
| 14 | +var __importStar = (this && this.__importStar) || function (mod) { |
| 15 | + if (mod && mod.__esModule) return mod; |
| 16 | + var result = {}; |
| 17 | + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
| 18 | + __setModuleDefault(result, mod); |
| 19 | + return result; |
| 20 | +}; |
| 21 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 22 | +exports.Status = exports.action = exports.TestFlag = void 0; |
| 23 | +const core_1 = require("@actions/core"); |
| 24 | +const github = __importStar(require("@actions/github")); |
| 25 | +const util_1 = require("./util"); |
| 26 | +const { pusher, repository } = github.context.payload; |
| 27 | +/* Flags to signal different scenarios to test cases */ |
| 28 | +var TestFlag; |
| 29 | +(function (TestFlag) { |
| 30 | + TestFlag[TestFlag["NONE"] = 0] = "NONE"; |
| 31 | + TestFlag[TestFlag["HAS_CHANGED_FILES"] = 2] = "HAS_CHANGED_FILES"; |
| 32 | + TestFlag[TestFlag["HAS_REMOTE_BRANCH"] = 4] = "HAS_REMOTE_BRANCH"; |
| 33 | + TestFlag[TestFlag["UNABLE_TO_REMOVE_ORIGIN"] = 8] = "UNABLE_TO_REMOVE_ORIGIN"; |
| 34 | + TestFlag[TestFlag["UNABLE_TO_UNSET_GIT_CONFIG"] = 16] = "UNABLE_TO_UNSET_GIT_CONFIG"; // Assume we can't remove previously set git configs. |
| 35 | +})(TestFlag = exports.TestFlag || (exports.TestFlag = {})); |
| 36 | +/* Required action data that gets initialized when running within the GitHub Actions environment. */ |
| 37 | +exports.action = { |
| 38 | + folder: (0, core_1.getInput)('folder'), |
| 39 | + branch: (0, core_1.getInput)('branch'), |
| 40 | + commitMessage: (0, core_1.getInput)('commit-message'), |
| 41 | + dryRun: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('dry-run')) |
| 42 | + ? (0, core_1.getInput)('dry-run').toLowerCase() === 'true' |
| 43 | + : false, |
| 44 | + clean: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('clean')) |
| 45 | + ? (0, core_1.getInput)('clean').toLowerCase() === 'true' |
| 46 | + : false, |
| 47 | + cleanExclude: ((0, core_1.getInput)('clean-exclude') || '') |
| 48 | + .split('\n') |
| 49 | + .filter(l => l !== ''), |
| 50 | + hostname: process.env.GITHUB_SERVER_URL |
| 51 | + ? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL) |
| 52 | + : 'github.com', |
| 53 | + isTest: TestFlag.NONE, |
| 54 | + email: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-email')) |
| 55 | + ? (0, core_1.getInput)('git-config-email') |
| 56 | + : pusher && pusher.email |
| 57 | + ? pusher.email |
| 58 | + : `${process.env.GITHUB_ACTOR || 'github-pages-deploy-action'}@users.noreply.${process.env.GITHUB_SERVER_URL |
| 59 | + ? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL) |
| 60 | + : 'github.com'}`, |
| 61 | + name: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-name')) |
| 62 | + ? (0, core_1.getInput)('git-config-name') |
| 63 | + : pusher && pusher.name |
| 64 | + ? pusher.name |
| 65 | + : process.env.GITHUB_ACTOR |
| 66 | + ? process.env.GITHUB_ACTOR |
| 67 | + : 'GitHub Pages Deploy Action', |
| 68 | + repositoryName: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('repository-name')) |
| 69 | + ? (0, core_1.getInput)('repository-name') |
| 70 | + : repository && repository.full_name |
| 71 | + ? repository.full_name |
| 72 | + : process.env.GITHUB_REPOSITORY, |
| 73 | + token: (0, core_1.getInput)('token'), |
| 74 | + singleCommit: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('single-commit')) |
| 75 | + ? (0, core_1.getInput)('single-commit').toLowerCase() === 'true' |
| 76 | + : false, |
| 77 | + silent: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('silent')) |
| 78 | + ? (0, core_1.getInput)('silent').toLowerCase() === 'true' |
| 79 | + : false, |
| 80 | + sshKey: (0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key')) |
| 81 | + ? false |
| 82 | + : !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key')) && |
| 83 | + (0, core_1.getInput)('ssh-key').toLowerCase() === 'true' |
| 84 | + ? true |
| 85 | + : (0, core_1.getInput)('ssh-key'), |
| 86 | + targetFolder: (0, core_1.getInput)('target-folder'), |
| 87 | + workspace: process.env.GITHUB_WORKSPACE || '' |
| 88 | +}; |
| 89 | +/** Status codes for the action. */ |
| 90 | +var Status; |
| 91 | +(function (Status) { |
| 92 | + Status["SUCCESS"] = "success"; |
| 93 | + Status["FAILED"] = "failed"; |
| 94 | + Status["SKIPPED"] = "skipped"; |
| 95 | + Status["RUNNING"] = "running"; |
| 96 | +})(Status = exports.Status || (exports.Status = {})); |
0 commit comments