From 3604e9d98b5e1fe454b19bfd08ae778dbcf1cb86 Mon Sep 17 00:00:00 2001 From: George Marshall Date: Thu, 25 Jun 2020 00:24:31 -0700 Subject: [PATCH] Add jekyll input option (#116) GitHub Pages will use Jekyll to build your site by default. This input option allows for this functionality to be disabled. The option is left to `true` by default as setting to `false` will cause the `.nojekyll` file to be written to the output directory. https://help.github.com/en/github/working-with-github-pages/about-github-pages#static-site-generators --- README.md | 1 + action.yml | 4 ++++ dist/index.js | 5 +++++ src/main.ts | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/README.md b/README.md index a2e6cf0..235393c 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ Following inputs can be used as `step.with` keys | `author` | String | Author name and email address as `Display Name ` (defaults to the GitHub Actions bot user) | | `commit_message` | String | Commit message (default `Deploy to GitHub pages`) | | `fqdn` | String | Write the given domain name to the CNAME file | +| `jekyll` | Bool | Allow Jekyll to build your site (default `true`) | ### environment variables diff --git a/action.yml b/action.yml index c4c7442..3cf99a9 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,10 @@ inputs: fqdn: description: 'Write the given domain name to the CNAME file' required: false + jekyll: + description: 'Allow Jekyll to build your site' + default: 'true' + required: false runs: using: 'node12' diff --git a/dist/index.js b/dist/index.js index a7a5e75..65b725d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1799,6 +1799,7 @@ function run() { const author = core.getInput('author') || git.defaults.author; const commitMessage = core.getInput('commit_message') || git.defaults.message; const fqdn = core.getInput('fqdn'); + const jekyll = /false/i.test(core.getInput('jekyll')); if (!fs.existsSync(buildDir)) { core.setFailed('Build dir does not exist'); return; @@ -1840,6 +1841,10 @@ function run() { core.info(`✍️ Writing ${fqdn} domain name to ${path.join(tmpdir, 'CNAME')}`); yield fs.writeFileSync(path.join(tmpdir, 'CNAME'), fqdn.trim()); } + if (jekyll) { + core.info(`🚫 Disabling Jekyll support via ${path.join(tmpdir, '.nojekyll')}`); + yield fs.writeFileSync(path.join(tmpdir, '.nojekyll'), ''); + } const isDirty = yield git.isDirty(); core.debug(`isDirty=${isDirty}`); if (keepHistory && remoteBranchExists && !isDirty) { diff --git a/src/main.ts b/src/main.ts index 572bb7f..1d4dbf9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,6 +17,7 @@ async function run() { const author: string = core.getInput('author') || git.defaults.author; const commitMessage: string = core.getInput('commit_message') || git.defaults.message; const fqdn: string = core.getInput('fqdn'); + const jekyll: boolean = /false/i.test(core.getInput('jekyll')); if (!fs.existsSync(buildDir)) { core.setFailed('Build dir does not exist'); @@ -63,6 +64,11 @@ async function run() { await fs.writeFileSync(path.join(tmpdir, 'CNAME'), fqdn.trim()); } + if (jekyll) { + core.info(`🚫 Disabling Jekyll support via ${path.join(tmpdir, '.nojekyll')}`); + await fs.writeFileSync(path.join(tmpdir, '.nojekyll'), ''); + } + const isDirty: boolean = await git.isDirty(); core.debug(`isDirty=${isDirty}`); if (keepHistory && remoteBranchExists && !isDirty) {