Skip to content

Commit

Permalink
feat: allow disabling auto install
Browse files Browse the repository at this point in the history
  • Loading branch information
sterlingwes committed Apr 24, 2024
1 parent e83b5c5 commit ff724fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: sterlingwes/gh-pages-deploy-action@v1.1
- uses: sterlingwes/gh-pages-deploy-action@v1.3
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
source-directory: public
Expand All @@ -31,13 +31,14 @@ jobs:
## Options
| Name | Description | Required? (default) |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| `access-token` | Required to push chages to your deployment branch. You can get this from your Github Settings > Developer Settings > [Personal Access Tokens](https://github.com/settings/tokens). **Note** that if you use a fine-grained token with content permissions you'll need to prefix the value of your secret with your username, ie: `myname:github_pat_*****` | Yes |
| `source-directory` | The name of the subfolder that holds the contents of the site you want deployed. This folder can be generated by your build command, or pre-exist. | Yes |
| `build-command` | The command you want this Action to run to generate your static site files in the `source-directory` you specify. | Yes |
| `deploy-branch` | The branch Github Pages is setup to source your site's files from. For the yourname.github.io site, this is typically the master branch. For /reponame subfolder deploys, `gh-pages` is the default. | No (gh-pages) |
| `custom-domain` | This is the domain that this Action will write to a `CNAME` file for you on your deploy branch, to enable a custom domain for your Github Pages site. | No |
| Name | Description | Required? (default) |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| `access-token` | Required to push chages to your deployment branch. You can get this from your Github Settings > Developer Settings > [Personal Access Tokens](https://github.com/settings/tokens). **Note** that if you use a fine-grained token with content permissions you'll need to prefix the value of your secret with your username, ie: `myname:github_pat_*****` | Yes |
| `source-directory` | The name of the subfolder that holds the contents of the site you want deployed. This folder can be generated by your build command, or pre-exist. | Yes |
| `build-command` | The command you want this Action to run to generate your static site files in the `source-directory` you specify. | Yes |
| `deploy-branch` | The branch Github Pages is setup to source your site's files from. For the yourname.github.io site, this is typically the master branch. For /reponame subfolder deploys, `gh-pages` is the default. | No (gh-pages) |
| `custom-domain` | This is the domain that this Action will write to a `CNAME` file for you on your deploy branch, to enable a custom domain for your Github Pages site. | No |
| `auto-install` | Whether to automatically install dependencies before running the build command (dependency manager detected based on presence of yarn.lock for yarn vs. npm). | No (Yes) |

## Related

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
description: 'The custom domain you want your Github Pages site to be served from.'
required: false
default: ''
auto-install:
description: 'Whether to automatically install dependencies before running the build command.'
required: false
default: 'yes'
runs:
using: 'node12'
main: 'dist/index.js'
15 changes: 9 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ async function run() {
return;
}

let pkgManager = (await ioUtil.exists('./yarn.lock')) ? 'yarn' : 'npm';
if (pkgManager === 'npm' && (await ioUtil.exists('./bun.lockb'))) {
pkgManager = 'bun';
const autoInstallInput = core.getInput('auto-install');
const autoInstall = autoInstallInput === 'true' || autoInstallInput === 'yes';
if (autoInstall) {
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.');
} else {
console.log('Skipping dependency installation (auto-install is disabled).');
}
console.log(`Installing your site's dependencies using ${pkgManager}.`);
await exec.exec(`${pkgManager} install`);
console.log('Finished installing dependencies.');

const buildCommand = core.getInput('build-command');
if (!buildCommand) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gh-pages-deploy-action",
"version": "1.2.0",
"version": "1.3.0",
"description": "GitHub Action to build and deploy a Github Pages site using the build command & output folder you specify.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ff724fb

Please sign in to comment.