Skip to content

Commit

Permalink
Apply PR suggestions (enriikke#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbach committed Apr 19, 2021
1 parent 3604058 commit d6db945
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inputs:
required: false
default: "."
commit-message:
description: "The commit message used for pushing changes to the deploy branch. Use the identifier {sha} to replace with the commit SHA."
description: "The commit message used for pushing changes to the deploy branch."
required: false
default: ""
git-config-name:
Expand Down
34 changes: 13 additions & 21 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,24 @@ async function run(): Promise<void> {
console.log('You can configure the deploy branch by setting the `deploy-branch` input for this action.')

await exec.exec(`git init`, [], {cwd: `${workingDir}/public`})
await exec.exec(`git config user.name`, [core.getInput('git-config-name') || github.context.actor], {

const gitUserName = core.getInput('git-config-name') || github.context.actor
const gitEmail = core.getInput('git-config-email') || `${github.context.actor}@users.noreply.github.com`

await exec.exec(`git config user.name`, [gitUserName], {
cwd: `${workingDir}/public`,
})
await exec.exec(`git config user.email`, [gitEmail], {
cwd: `${workingDir}/public`,
})
await exec.exec(
`git config user.email`,
[core.getInput('git-config-email') || `${github.context.actor}@users.noreply.github.com`],
{
cwd: `${workingDir}/public`,
},
)

await exec.exec(`git add`, ['.'], {cwd: `${workingDir}/public`})

const commitMessageInput = core.getInput('commit-message')
await exec.exec(
`git commit`,
[
'-m',
commitMessageInput
? commitMessageInput.replace('{sha}', github.context.sha)
: `deployed via Gatsby Publish Action 🎩 for ${github.context.sha}`,
],
{
cwd: `${workingDir}/public`,
},
)
const commitMessageInput =
core.getInput('commit-message') ?? `deployed via Gatsby Publish Action 🎩 for ${github.context.sha}`
await exec.exec(`git commit`, ['-m', commitMessageInput], {
cwd: `${workingDir}/public`,
})

await exec.exec(`git push`, ['-f', repoURL, `master:${deployBranch}`], {
cwd: `${workingDir}/public`,
Expand Down

0 comments on commit d6db945

Please sign in to comment.