2019-11-19 23:06:27 +08:00
|
|
|
import * as core from "@actions/core";
|
|
|
|
import * as github from "@actions/github";
|
|
|
|
|
|
|
|
const { pusher, repository } = github.context.payload;
|
|
|
|
|
|
|
|
export const workspace: any = process.env.GITHUB_WORKSPACE;
|
|
|
|
export const folder = core.getInput("FOLDER", { required: true });
|
2019-11-20 22:13:01 +08:00
|
|
|
export const isTest = process.env.UNIT_TEST;
|
2020-01-20 02:15:19 +08:00
|
|
|
export const root = ".";
|
2019-11-19 23:06:27 +08:00
|
|
|
|
|
|
|
// Required action data.
|
|
|
|
export const action = {
|
2020-01-19 03:41:49 +08:00
|
|
|
accessToken: core.getInput("ACCESS_TOKEN"),
|
|
|
|
baseBranch: core.getInput("BASE_BRANCH"),
|
2019-11-19 23:06:27 +08:00
|
|
|
build: folder,
|
2020-01-19 03:41:49 +08:00
|
|
|
branch: core.getInput("BRANCH"),
|
|
|
|
commitMessage: core.getInput("COMMIT_MESSAGE"),
|
|
|
|
clean: core.getInput("CLEAN"),
|
|
|
|
cleanExclude: core.getInput("CLEAN_EXCLUDE"),
|
|
|
|
defaultBranch: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : "master",
|
2020-01-20 02:15:19 +08:00
|
|
|
ssh: core.getInput("SSH"),
|
2020-01-19 03:41:49 +08:00
|
|
|
email:
|
|
|
|
pusher && pusher.email
|
|
|
|
? pusher.email
|
|
|
|
: `${process.env.GITHUB_ACTOR ||
|
|
|
|
"github-pages-deploy-action"}@users.noreply.github.com`,
|
2019-11-21 22:29:43 +08:00
|
|
|
gitHubRepository:
|
|
|
|
repository && repository.full_name
|
|
|
|
? repository.full_name
|
|
|
|
: process.env.GITHUB_REPOSITORY,
|
2019-11-19 23:06:27 +08:00
|
|
|
gitHubToken: core.getInput("GITHUB_TOKEN"),
|
2019-11-22 23:01:06 +08:00
|
|
|
name:
|
|
|
|
pusher && pusher.name
|
|
|
|
? pusher.name
|
|
|
|
: process.env.GITHUB_ACTOR
|
|
|
|
? process.env.GITHUB_ACTOR
|
|
|
|
: "GitHub Pages Deploy Action",
|
2020-01-19 03:41:49 +08:00
|
|
|
targetFolder: core.getInput("TARGET_FOLDER")
|
2019-11-19 23:06:27 +08:00
|
|
|
};
|
|
|
|
|
2020-01-20 02:15:19 +08:00
|
|
|
// Token Types
|
|
|
|
export const tokenType = action.ssh
|
|
|
|
? "SSH"
|
|
|
|
: action.accessToken
|
|
|
|
? "Access Token"
|
|
|
|
: action.gitHubToken
|
|
|
|
? "GitHub Token"
|
|
|
|
: "...";
|
|
|
|
|
2019-11-19 23:06:27 +08:00
|
|
|
// Repository path used for commits/pushes.
|
2020-01-20 02:15:19 +08:00
|
|
|
export const repositoryPath = action.ssh
|
|
|
|
? `git@github.com:${action.gitHubRepository}`
|
|
|
|
: `https://${action.accessToken ||
|
|
|
|
`x-access-token:${action.gitHubToken}`}@github.com/${
|
|
|
|
action.gitHubRepository
|
|
|
|
}.git`;
|