github-pages-deploy-action/src/constants.ts

87 lines
3.6 KiB
TypeScript
Raw Normal View History

2020-03-05 21:19:45 +08:00
import {getInput} from '@actions/core'
import * as github from '@actions/github'
import {isNullOrUndefined} from './util'
2020-03-05 21:19:45 +08:00
const {pusher, repository} = github.context.payload
/* For more information please refer to the README: https://github.com/JamesIves/github-pages-deploy-action */
2020-03-07 11:36:56 +08:00
export interface ActionInterface {
/** Deployment access token. */
2020-03-05 21:19:45 +08:00
accessToken?: string | null
/** The base branch that the deploy should be made from. */
2020-03-05 21:19:45 +08:00
baseBranch?: string
/** The branch that the action should deploy to. */
2020-03-05 21:19:45 +08:00
branch: string
/** 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. */
2020-03-05 21:19:45 +08:00
clean?: string | boolean
/** If you need to use CLEAN but you'd like to preserve certain files or folders you can use this option. */
2020-03-07 11:36:56 +08:00
cleanExclude?: string | string[]
/** If you need to customize the commit message for an integration you can do so. */
2020-03-05 21:19:45 +08:00
commitMessage?: string
/** Unhides the Git commands from the function terminal. */
2020-03-05 21:19:45 +08:00
debug?: boolean | string
/** The default branch of the deployment. Similar to baseBranch if you're using this action as a module. */
2020-03-05 21:19:45 +08:00
defaultBranch?: string
/** The git config email. */
2020-03-05 21:19:45 +08:00
email?: string
/** The folder to deploy. */
2020-03-05 21:19:45 +08:00
folder: string
/** GitHub deployment token. */
2020-03-05 21:19:45 +08:00
gitHubToken?: string | null
/** Determines if the action is running in test mode or not. */
2020-03-05 21:19:45 +08:00
isTest?: string | undefined | null
/** The git config name. */
2020-03-05 21:19:45 +08:00
name?: string
2020-03-09 21:19:16 +08:00
/** The repository path, for example JamesIves/github-pages-deploy-action. */
2020-03-05 21:19:45 +08:00
repositoryName?: string
2020-03-02 21:37:55 +08:00
/** The fully qualified repositpory path, this gets auto generated if repositoryName is provided. */
2020-03-05 21:19:45 +08:00
repositoryPath?: string
/** The root directory where your project lives. */
2020-03-05 21:19:45 +08:00
root?: string
/** Set to true if you're using an ssh client in your build step. */
2020-03-05 21:19:45 +08:00
ssh?: 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. */
2020-03-05 21:19:45 +08:00
targetFolder?: string
/** The token type, ie ssh/github token/access token, this gets automatically generated. */
2020-03-05 21:19:45 +08:00
tokenType?: string
/** The folder where your deployment project lives. */
2020-03-05 21:19:45 +08:00
workspace: string
}
/* Required action data that gets initialized when running within the GitHub Actions environment. */
2020-03-07 11:36:56 +08:00
export const action: ActionInterface = {
2020-03-05 21:19:45 +08:00
accessToken: getInput('ACCESS_TOKEN'),
baseBranch: getInput('BASE_BRANCH'),
folder: getInput('FOLDER'),
branch: getInput('BRANCH'),
commitMessage: getInput('COMMIT_MESSAGE'),
clean: getInput('CLEAN'),
cleanExclude: getInput('CLEAN_EXCLUDE'),
debug: getInput('DEBUG'),
defaultBranch: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : 'master',
isTest: process.env.UNIT_TEST,
2020-03-05 21:19:45 +08:00
ssh: getInput('SSH'),
email: !isNullOrUndefined(getInput('GIT_CONFIG_EMAIL'))
? getInput('GIT_CONFIG_EMAIL')
: pusher && pusher.email
? pusher.email
: `${process.env.GITHUB_ACTOR ||
2020-03-05 21:19:45 +08:00
'github-pages-deploy-action'}@users.noreply.github.com`,
gitHubToken: getInput('GITHUB_TOKEN'),
name: !isNullOrUndefined(getInput('GIT_CONFIG_NAME'))
? getInput('GIT_CONFIG_NAME')
: pusher && pusher.name
? pusher.name
: process.env.GITHUB_ACTOR
? process.env.GITHUB_ACTOR
2020-03-05 21:19:45 +08:00
: 'GitHub Pages Deploy Action',
repositoryName: !isNullOrUndefined(getInput('REPOSITORY_NAME'))
? getInput('REPOSITORY_NAME')
2020-03-02 21:37:55 +08:00
: repository && repository.full_name
? repository.full_name
: process.env.GITHUB_REPOSITORY,
2020-03-05 21:19:45 +08:00
root: '.',
targetFolder: getInput('TARGET_FOLDER'),
workspace: process.env.GITHUB_WORKSPACE || ''
}