2020-03-05 21:19:45 +08:00
import { getInput } from '@actions/core'
import * as github from '@actions/github'
import { isNullOrUndefined } from './util'
2019-11-19 23:06:27 +08:00
2020-03-05 21:19:45 +08:00
const { pusher , repository } = github . context . payload
2019-11-19 23:06:27 +08:00
2020-03-02 20:52:38 +08:00
/* 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 {
2020-03-02 20:52:38 +08:00
/** Deployment access token. */
2020-03-05 21:19:45 +08:00
accessToken? : string | null
2020-03-02 20:52:38 +08:00
/** The base branch that the deploy should be made from. */
2020-03-05 21:19:45 +08:00
baseBranch? : string
2020-03-02 20:52:38 +08:00
/** The branch that the action should deploy to. */
2020-03-05 21:19:45 +08:00
branch : string
2020-03-02 20:52:38 +08:00
/** 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
2020-03-02 20:52:38 +08:00
/** 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 [ ]
2020-03-02 20:52:38 +08:00
/** 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
2020-03-02 20:52:38 +08:00
/** Unhides the Git commands from the function terminal. */
2020-03-05 21:19:45 +08:00
debug? : boolean | string
2020-03-02 20:52:38 +08:00
/** 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
2020-03-02 20:52:38 +08:00
/** The git config email. */
2020-03-05 21:19:45 +08:00
email? : string
2020-03-02 20:52:38 +08:00
/** The folder to deploy. */
2020-03-05 21:19:45 +08:00
folder : string
2020-03-02 20:52:38 +08:00
/** GitHub deployment token. */
2020-03-05 21:19:45 +08:00
gitHubToken? : string | null
2020-03-02 20:52:38 +08:00
/** Determines if the action is running in test mode or not. */
2020-03-05 21:19:45 +08:00
isTest? : string | undefined | null
2020-03-02 20:52:38 +08:00
/** 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
2020-03-02 20:52:38 +08:00
/** The root directory where your project lives. */
2020-03-05 21:19:45 +08:00
root? : string
2020-03-02 20:52:38 +08:00
/** 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
2020-03-02 20:52:38 +08:00
/** 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
2020-03-02 20:52:38 +08:00
/** The token type, ie ssh/github token/access token, this gets automatically generated. */
2020-03-05 21:19:45 +08:00
tokenType? : string
2020-03-02 20:52:38 +08:00
/** The folder where your deployment project lives. */
2020-03-05 21:19:45 +08:00
workspace : string
2020-03-02 20:52:38 +08:00
}
2019-11-19 23:06:27 +08:00
2020-03-02 20:52:38 +08:00
/* 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' ,
2020-01-20 04:33:14 +08:00
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' )
2020-01-28 12:55:28 +08:00
: 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' )
2020-01-28 12:55:28 +08:00
: 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 || ''
}