-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { ActionInterface } from './constants'; | ||
import { deploy, generateBranch, init } from './git'; | ||
import { ActionInterface, NodeActionInterface } from './constants'; | ||
/** Initializes and runs the action. | ||
* | ||
* @param {object} configuration - The action configuration. | ||
*/ | ||
export default function run(configuration: ActionInterface): Promise<void>; | ||
export { init, deploy, generateBranch, ActionInterface }; | ||
export default function run(configuration: ActionInterface | NodeActionInterface): Promise<void>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.suppressSensitiveInformation = exports.hasRequiredParameters = exports.generateRepositoryPath = exports.generateTokenType = exports.isNullOrUndefined = void 0; | ||
exports.suppressSensitiveInformation = exports.checkParameters = exports.generateFolderPath = exports.generateRepositoryPath = exports.generateTokenType = exports.isNullOrUndefined = void 0; | ||
const fs_1 = require("fs"); | ||
const path_1 = __importDefault(require("path")); | ||
const core_1 = require("@actions/core"); | ||
/* 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. */ | ||
exports.isNullOrUndefined = (value) => typeof value === 'undefined' || value === null || value === ''; | ||
|
@@ -17,23 +23,33 @@ exports.generateTokenType = (action) => action.ssh | |
exports.generateRepositoryPath = (action) => action.ssh | ||
? `[email protected]:${action.repositoryName}` | ||
: `https://${action.accessToken || `x-access-token:${action.gitHubToken}`}@github.com/${action.repositoryName}.git`; | ||
/* Genetate absolute folder path by the provided folder name */ | ||
exports.generateFolderPath = (action) => { | ||
const folderName = action['folder']; | ||
return path_1.default.isAbsolute(folderName) | ||
? folderName | ||
: folderName.startsWith('~') | ||
? folderName.replace('~', process.env.HOME) | ||
: path_1.default.join(action.workspace, folderName); | ||
}; | ||
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */ | ||
exports.hasRequiredParameters = (action) => { | ||
if ((exports.isNullOrUndefined(action.accessToken) && | ||
exports.isNullOrUndefined(action.gitHubToken) && | ||
exports.isNullOrUndefined(action.ssh)) || | ||
exports.isNullOrUndefined(action.repositoryPath) || | ||
(action.accessToken && action.accessToken === '')) { | ||
const hasRequiredParameters = (action, params) => { | ||
const nonNullParams = params.filter(param => !exports.isNullOrUndefined(action[param])); | ||
return Boolean(nonNullParams.length); | ||
}; | ||
/* Verifies the action has the required parameters to run, otherwise throw an error. */ | ||
exports.checkParameters = (action) => { | ||
if (!hasRequiredParameters(action, ['accessToken', 'gitHubToken', 'ssh'])) { | ||
throw new Error('No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'); | ||
} | ||
if (exports.isNullOrUndefined(action.branch)) { | ||
if (!hasRequiredParameters(action, ['branch'])) { | ||
throw new Error('Branch is required.'); | ||
} | ||
if (!action.folder || exports.isNullOrUndefined(action.folder)) { | ||
if (!hasRequiredParameters(action, ['folder'])) { | ||
throw new Error('You must provide the action with a folder to deploy.'); | ||
} | ||
if (action.folder.startsWith('/') || action.folder.startsWith('./')) { | ||
throw new Error("Incorrectly formatted build folder. The deployment folder cannot be prefixed with '/' or './'. Instead reference the folder name directly."); | ||
if (!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. ❗`); | ||
} | ||
}; | ||
/* Suppresses sensitive information from being exposed in error messages. */ | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.