-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from enriikke/migrate-to-new-syntax
Migrate to JavaScript action
- Loading branch information
Showing
395 changed files
with
78,727 additions
and
155 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "Gatsby Publish" | ||
description: "Build and deploy your Gatsby site to GitHub Pages." | ||
branding: | ||
icon: "book-open" | ||
color: "purple" | ||
inputs: | ||
access-token: | ||
description: "A personal access token needed to push your site after it has been built." | ||
required: true | ||
deploy-branch: | ||
description: "The branch expected by GitHub to have the static files needed for your site." | ||
required: false | ||
default: "master" | ||
gatsby-args: | ||
description: "Additional arguments that get passed to `gatsby build`." | ||
required: false | ||
default: "" | ||
runs: | ||
using: "node12" | ||
main: "index.js" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const core = require("@actions/core") | ||
const github = require("@actions/github") | ||
const ioUtil = require("@actions/io/lib/io-util") | ||
const exec = require("@actions/exec") | ||
|
||
async function run() { | ||
try { | ||
const accessToken = core.getInput("access-token") | ||
if (!accessToken) { | ||
core.setFailed( | ||
"No personal access token found. Please provide one by setting the `access-token` input for this action." | ||
) | ||
return | ||
} | ||
|
||
const deployBranch = core.getInput("deploy-branch") | ||
if (!deployBranch) deployBranch = "master" | ||
|
||
if (github.context.ref === `refs/heads/${deployBranch}`) { | ||
console.log(`Triggered by branch used to deploy: ${github.context.ref}.`) | ||
console.log("Nothing to deploy.") | ||
return | ||
} | ||
|
||
const pkgManager = (await ioUtil.exists("./yarn.lock")) ? "yarn" : "npm" | ||
console.log(`Installing your site's dependencies using ${pkgManager}.`) | ||
await exec.exec(`${pkgManager} install`) | ||
console.log("Finished installing dependencies.") | ||
|
||
const gatsbyArgs = core.getInput("gatsby-args") | ||
console.log("Ready to build your Gatsby site!") | ||
console.log(`Building with: ${pkgManager} run gatsby build ${gatsbyArgs}`) | ||
await exec.exec(`${pkgManager} run gatsby build`, [gatsbyArgs]) | ||
console.log("Finished buidling your site.") | ||
|
||
// TODO: copy CNAME to ./public | ||
|
||
const repo = `${github.context.repo.owner}/${github.context.repo.repo}` | ||
const repoURL = `https://${accessToken}@github.com/${repo}.git` | ||
console.log("Ready to deploy your new shiny site!") | ||
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." | ||
) | ||
await exec.exec(`git init`, [], { cwd: "./public" }) | ||
await exec.exec(`git config user.name`, [github.context.actor], { | ||
cwd: "./public", | ||
}) | ||
await exec.exec( | ||
`git config user.email`, | ||
[`${github.context.actor}@users.noreply.github.com`], | ||
{ cwd: "./public" } | ||
) | ||
await exec.exec(`git add`, ["."], { cwd: "./public" }) | ||
await exec.exec( | ||
`git commit`, | ||
["-m", `deployed via Gatsby Publish Action 🎩 for ${github.context.sha}`], | ||
{ cwd: "./public" } | ||
) | ||
await exec.exec(`git push`, ["-f", repoURL, `master:${deployBranch}`], { | ||
cwd: "./public", | ||
}) | ||
console.log("Finished deploying your site.") | ||
|
||
console.log("Enjoy! ✨") | ||
} catch (error) { | ||
core.setFailed(error.message) | ||
} | ||
} | ||
|
||
run() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.