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
afcfd7b3a1
commit
a16ac09dc1
67
src/git.ts
67
src/git.ts
@ -21,52 +21,37 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
|||||||
info(`Deploying using ${action.tokenType}… 🔑`)
|
info(`Deploying using ${action.tokenType}… 🔑`)
|
||||||
info('Configuring git…')
|
info('Configuring git…')
|
||||||
|
|
||||||
async function configureGit(throwOnError: boolean) {
|
await execute(`git init`, action.workspace, action.silent)
|
||||||
try {
|
|
||||||
await execute(
|
|
||||||
`git config --global --add safe.directory "${action.workspace}"`,
|
|
||||||
action.workspace,
|
|
||||||
action.silent
|
|
||||||
)
|
|
||||||
|
|
||||||
await execute(
|
await execute(
|
||||||
`git config user.name "${action.name}"`,
|
`git commit -m "Initial commit" --allow-empty`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
action.silent
|
action.silent
|
||||||
)
|
)
|
||||||
|
|
||||||
await execute(
|
await execute(
|
||||||
`git config user.email "${action.email}"`,
|
`git config --global --add safe.directory "${action.workspace}"`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
action.silent
|
action.silent
|
||||||
)
|
)
|
||||||
|
|
||||||
await execute(
|
await execute(
|
||||||
`git config core.ignorecase false`,
|
`git config user.name "${action.name}"`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
action.silent
|
action.silent
|
||||||
)
|
)
|
||||||
} catch {
|
|
||||||
if (throwOnError) {
|
|
||||||
throw new Error()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
await execute(
|
||||||
await configureGit(false)
|
`git config user.email "${action.email}"`,
|
||||||
} catch {
|
action.workspace,
|
||||||
// Attempt to re-run if initial configuration failed using git init.
|
action.silent
|
||||||
await execute(`git init`, action.workspace, action.silent)
|
)
|
||||||
|
|
||||||
await execute(
|
await execute(
|
||||||
`git commit -m "Initial commit" --allow-empty`,
|
`git config core.ignorecase false`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
action.silent
|
action.silent
|
||||||
)
|
)
|
||||||
|
|
||||||
await configureGit(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ((process.env.CI && !action.sshKey) || action.isTest) {
|
if ((process.env.CI && !action.sshKey) || action.isTest) {
|
||||||
|
Loading…
Reference in New Issue
Block a user