Skip to content

Commit

Permalink
Support for custom deploy user (enriikke#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbach committed Feb 11, 2021
1 parent bf3ba06 commit 3604058
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ inputs:
description: "The directory where your Gatsby source files are at. `gatsby build` will run from this directory."
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."
required: false
default: ""
git-config-name:
description: "The name under which the deploy commit is pushed to the deploy branch."
required: false
default: ""
git-config-email:
description: "The email adress under which the deploy commit is pushed to the deploy branch."
required: false
default: ""
runs:
using: "node12"
main: "./dist/index.js"
29 changes: 22 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,32 @@ 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`, [github.context.actor], {
cwd: `${workingDir}/public`,
})
await exec.exec(`git config user.email`, [`${github.context.actor}@users.noreply.github.com`], {
await exec.exec(`git config user.name`, [core.getInput('git-config-name') || github.context.actor], {
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`})
await exec.exec(`git commit`, ['-m', `deployed via Gatsby Publish Action 🎩 for ${github.context.sha}`], {
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`,
},
)

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

0 comments on commit 3604058

Please sign in to comment.