diff --git a/README.md b/README.md index f278aa0..b886009 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/action.yml b/action.yml index 9f42d2c..2923933 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/index.js b/index.js index a5a444f..8abaf6d 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/package.json b/package.json index 2f46565..3f0a418 100644 --- a/package.json +++ b/package.json @@ -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": {