mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Merge branch 'init-commit' into releases/v4-init
This commit is contained in:
commit
781d9e3ced
70
src/git.ts
70
src/git.ts
@ -21,55 +21,37 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
||||
info(`Deploying using ${action.tokenType}… 🔑`)
|
||||
info('Configuring git…')
|
||||
|
||||
async function configure(throwOnError: boolean) {
|
||||
try {
|
||||
await execute(
|
||||
`git config --global --add safe.directory "${action.workspace}"`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
await execute(`git init`, action.workspace, action.silent)
|
||||
|
||||
await execute(
|
||||
`git config user.name "${action.name}"`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
await execute(
|
||||
`git commit -m "Initial commit" --allow-empty`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
await execute(
|
||||
`git config user.email "${action.email}"`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
await execute(
|
||||
`git config --global --add safe.directory "${action.workspace}"`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
await execute(
|
||||
`git config core.ignorecase false`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
} catch {
|
||||
info(
|
||||
'There was a problemissue initilizing git, attempting to resolve …'
|
||||
)
|
||||
if (throwOnError) {
|
||||
throw new Error()
|
||||
}
|
||||
}
|
||||
}
|
||||
await execute(
|
||||
`git config user.name "${action.name}"`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
try {
|
||||
await configure(false)
|
||||
} catch {
|
||||
// Attempt to re-run if initial configuration failed using git init.
|
||||
await execute(`git init`, action.workspace, action.silent)
|
||||
await execute(
|
||||
`git config user.email "${action.email}"`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
await execute(
|
||||
`git commit -m "Initial commit" --allow-empty`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
await configure(true)
|
||||
}
|
||||
await execute(
|
||||
`git config core.ignorecase false`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
try {
|
||||
if ((process.env.CI && !action.sshKey) || action.isTest) {
|
||||
|
Loading…
Reference in New Issue
Block a user