Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
suziwen committed Dec 11, 2021
1 parent 5d1cab9 commit 5948f18
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ async function run(): Promise<void> {
}

const workingDir = core.getInput('working-dir') || '.'

const exists = await ioUtil.exists(`${workingDir}/public/.git/config`)
if (exists) {
await exec.exec(`git status`, [], {
cwd: `${workingDir}/public`,
})
await exec.exec(`git branch`, ['--all'], {
cwd: `${workingDir}/public`,
})
await exec.exec(`git switch`, ['-c', `${deployBranch}`], {cwd: `${workingDir}/public`})
}

const pkgManager = (await ioUtil.exists(`${workingDir}/yarn.lock`)) ? 'yarn' : 'npm'
console.log(`Installing your site's dependencies using ${pkgManager}.`)
await exec.exec(`${pkgManager} install`, [], {cwd: workingDir})
Expand Down Expand Up @@ -63,17 +75,8 @@ async function run(): Promise<void> {
console.log(`Deploying to repo: ${repo} and branch: ${deployBranch}`)
console.log('You can configure the deploy branch by setting the `deploy-branch` input for this action.')

const exists = await ioUtil.exists(`${workingDir}/public/.git/config`)
if (!exists) {
await exec.exec(`git init`, [], {cwd: `${workingDir}/public`})
} else {
await exec.exec(`git state`, [], {
cwd: `${workingDir}/public`,
})
await exec.exec(`git branch`, ['--all'], {
cwd: `${workingDir}/public`,
})
await exec.exec(`git switch`, ['-c', `${deployBranch}`], {cwd: `${workingDir}/public`})
}

const gitUserName = core.getInput('git-config-name') || github.context.actor
Expand Down

0 comments on commit 5948f18

Please sign in to comment.