mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Update git.ts
This commit is contained in:
parent
23923d7904
commit
ff7201a4d8
22
src/git.ts
22
src/git.ts
@ -12,8 +12,8 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
|||||||
try {
|
try {
|
||||||
hasRequiredParameters(action)
|
hasRequiredParameters(action)
|
||||||
|
|
||||||
info(`Deploying using ${action.tokenType}... 🔑`)
|
info(`Deploying using ${action.tokenType}… 🔑`)
|
||||||
info('Configuring git...')
|
info('Configuring git…')
|
||||||
|
|
||||||
await execute(`git init`, action.workspace)
|
await execute(`git init`, action.workspace)
|
||||||
await execute(`git config user.name "${action.name}"`, action.workspace)
|
await execute(`git config user.name "${action.name}"`, action.workspace)
|
||||||
@ -30,7 +30,7 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
|||||||
|
|
||||||
await execute(`git fetch`, action.workspace)
|
await execute(`git fetch`, action.workspace)
|
||||||
|
|
||||||
info('Git configured... 🔧')
|
info('Git configured… 🔧')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`There was an error initializing the repository: ${suppressSensitiveInformation(
|
`There was an error initializing the repository: ${suppressSensitiveInformation(
|
||||||
@ -69,13 +69,13 @@ export async function generateBranch(action: ActionInterface): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
hasRequiredParameters(action)
|
hasRequiredParameters(action)
|
||||||
|
|
||||||
info(`Creating the ${action.branch} branch...`)
|
info(`Creating the ${action.branch} branch…`)
|
||||||
|
|
||||||
await switchToBaseBranch(action)
|
await switchToBaseBranch(action)
|
||||||
await execute(`git checkout --orphan ${action.branch}`, action.workspace)
|
await execute(`git checkout --orphan ${action.branch}`, action.workspace)
|
||||||
await execute(`git reset --hard`, action.workspace)
|
await execute(`git reset --hard`, action.workspace)
|
||||||
await execute(
|
await execute(
|
||||||
`git commit --allow-empty -m "Initial ${action.branch} commit."`,
|
`git commit --allow-empty -m "Initial ${action.branch} commit"`,
|
||||||
action.workspace
|
action.workspace
|
||||||
)
|
)
|
||||||
await execute(
|
await execute(
|
||||||
@ -84,7 +84,7 @@ export async function generateBranch(action: ActionInterface): Promise<void> {
|
|||||||
)
|
)
|
||||||
await execute(`git fetch`, action.workspace)
|
await execute(`git fetch`, action.workspace)
|
||||||
|
|
||||||
info(`Created the ${action.branch} branch... 🔧`)
|
info(`Created the ${action.branch} branch… 🔧`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`There was an error creating the deployment branch: ${suppressSensitiveInformation(
|
`There was an error creating the deployment branch: ${suppressSensitiveInformation(
|
||||||
@ -99,7 +99,7 @@ export async function generateBranch(action: ActionInterface): Promise<void> {
|
|||||||
export async function deploy(action: ActionInterface): Promise<void> {
|
export async function deploy(action: ActionInterface): Promise<void> {
|
||||||
const temporaryDeploymentDirectory = 'gh-action-temp-deployment-folder'
|
const temporaryDeploymentDirectory = 'gh-action-temp-deployment-folder'
|
||||||
const temporaryDeploymentBranch = 'gh-action-temp-deployment-branch'
|
const temporaryDeploymentBranch = 'gh-action-temp-deployment-branch'
|
||||||
info('Starting to commit changes...')
|
info('Starting to commit changes…')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
hasRequiredParameters(action)
|
hasRequiredParameters(action)
|
||||||
@ -171,7 +171,7 @@ export async function deploy(action: ActionInterface): Promise<void> {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!hasFilesToCommit && !action.isTest) {
|
if (!hasFilesToCommit && !action.isTest) {
|
||||||
info('There is nothing to commit. Exiting early... 📭')
|
info('There is nothing to commit. Exiting early… 📭')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ export async function deploy(action: ActionInterface): Promise<void> {
|
|||||||
? action.commitMessage
|
? action.commitMessage
|
||||||
: `Deploying to ${action.branch} from ${action.baseBranch}`
|
: `Deploying to ${action.branch} from ${action.baseBranch}`
|
||||||
} ${
|
} ${
|
||||||
process.env.GITHUB_SHA ? `- ${process.env.GITHUB_SHA}` : ''
|
process.env.GITHUB_SHA ? `@ ${process.env.GITHUB_SHA}` : ''
|
||||||
} 🚀" --quiet`,
|
} 🚀" --quiet`,
|
||||||
`${action.workspace}/${temporaryDeploymentDirectory}`
|
`${action.workspace}/${temporaryDeploymentDirectory}`
|
||||||
)
|
)
|
||||||
@ -199,10 +199,10 @@ export async function deploy(action: ActionInterface): Promise<void> {
|
|||||||
`${action.workspace}/${temporaryDeploymentDirectory}`
|
`${action.workspace}/${temporaryDeploymentDirectory}`
|
||||||
)
|
)
|
||||||
|
|
||||||
info(`Changes committed to the ${action.branch} branch... 📦`)
|
info(`Changes committed to the ${action.branch} branch… 📦`)
|
||||||
|
|
||||||
// Cleans up temporary files/folders and restores the git state.
|
// Cleans up temporary files/folders and restores the git state.
|
||||||
info('Running post deployment cleanup jobs...')
|
info('Running post deployment cleanup jobs…')
|
||||||
await execute(
|
await execute(
|
||||||
`git checkout --progress --force ${action.defaultBranch}`,
|
`git checkout --progress --force ${action.defaultBranch}`,
|
||||||
action.workspace
|
action.workspace
|
||||||
|
Loading…
Reference in New Issue
Block a user