From 48f1e561a33dabbd54dbffa156d0fb4856784ac7 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Sat, 6 Nov 2021 12:12:54 +0100 Subject: [PATCH 1/4] Install node using nvm --- Dockerfile | 2 +- entrypoint.sh | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7118a39..d09bbe2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:current-stretch-slim +FROM node:current-stretch ADD entrypoint.sh /entrypoint.sh ADD action.yml /action.yml diff --git a/entrypoint.sh b/entrypoint.sh index ecd7fa6..25a2d18 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,17 @@ #!/bin/bash +# Install netlify globally before NVM to prevent EACCESS issues npm i -g netlify-cli +# Save its exec path to run later +NETLIFY_CLI=$(which netlify) + +# Install node from NVM to honor .nvmrc files +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash +[ -s "$HOME/.nvm/nvm.sh" ] && \. "$HOME/.nvm/nvm.sh" + +nvm install + NETLIFY_AUTH_TOKEN=$1 NETLIFY_SITE_ID=$2 NETLIFY_DEPLOY_TO_PROD=$3 @@ -29,7 +39,7 @@ eval ${BUILD_COMMAND:-"npm run build"} export NETLIFY_SITE_ID=$NETLIFY_SITE_ID export NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN -COMMAND="netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message=\"$INPUT_NETLIFY_DEPLOY_MESSAGE\"" +COMMAND="$NETLIFY_CLI deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message=\"$INPUT_NETLIFY_DEPLOY_MESSAGE\"" if [[ $NETLIFY_DEPLOY_TO_PROD == "true" ]] then From cef739626ce45878018895fd39512bf86f1332ba Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Sat, 6 Nov 2021 20:01:34 +0100 Subject: [PATCH 2/4] docs: mention nvm --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index b226646..2e0785d 100644 --- a/README.md +++ b/README.md @@ -134,3 +134,9 @@ jobs: state: success target_url: https://${{ env.BRANCH_NAME }}--my-site.netlify.app ``` + +### Selecting node version + +By default, the latest node will be installed before buidling the application. + +To select a different release, create an `.nvmrc` file with the desired version range. From 643fe046dee0e57cdc115f28b5b2de4627138bdf Mon Sep 17 00:00:00 2001 From: tpluscode Date: Wed, 10 Nov 2021 08:47:45 +0100 Subject: [PATCH 3/4] feat: add node version as input --- README.md | 7 +++++-- action.yml | 8 +++++++- entrypoint.sh | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e0785d..fdc8451 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ The inputs this action uses are: | `install_command` | `false` | Auto-detected | The (optional) command to install dependencies. Runs `yarn` when `yarn.lock` is found; `npm i` otherwise | | `build_command` | `false` | `npm run build` | The (optional) command to build static website | | `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) | +| `node_version` | `false` | '' | (Optional) Node version or other arguments passed to [nvm install](https://github.com/nvm-sh/nvm#usage) | ## Example @@ -137,6 +138,8 @@ jobs: ### Selecting node version -By default, the latest node will be installed before buidling the application. +By default, the latest node will be installed before building the application. -To select a different release, create an `.nvmrc` file with the desired version range. +Use the `node_version` input to change the desired version. It will be passed to [`nvm install`](https://github.com/nvm-sh/nvm#usage). Valid examples include `16.3.0`, `14`, or `--lts`. + +Alternatively, create an `.nvmrc` file with the desired version range in your repository. diff --git a/action.yml b/action.yml index d810805..1c2fbb9 100644 --- a/action.yml +++ b/action.yml @@ -42,12 +42,17 @@ inputs: description: 'Command to build static website' required: false default: 'npm run build' - + deploy_alias: description: 'Deployment Subdomain name' required: false default: '' + node_version: + description: 'Node version or arguments compatible with `nvm install`' + required: false + default: '' + runs: using: 'docker' image: 'Dockerfile' @@ -60,6 +65,7 @@ runs: - ${{ inputs.install_command }} - ${{ inputs.build_command }} - ${{ inputs.deploy_alias }} + - ${{ inputs.node_version }} branding: icon: activity diff --git a/entrypoint.sh b/entrypoint.sh index 25a2d18..ac014da 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,7 +10,7 @@ NETLIFY_CLI=$(which netlify) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash [ -s "$HOME/.nvm/nvm.sh" ] && \. "$HOME/.nvm/nvm.sh" -nvm install +nvm install "$9" NETLIFY_AUTH_TOKEN=$1 NETLIFY_SITE_ID=$2 From 85b77006d074697b31401c643c17ee14351f93ea Mon Sep 17 00:00:00 2001 From: tpluscode Date: Wed, 10 Nov 2021 08:48:10 +0100 Subject: [PATCH 4/4] chore: mention myself in readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index fdc8451..cf18382 100644 --- a/README.md +++ b/README.md @@ -143,3 +143,7 @@ By default, the latest node will be installed before building the application. Use the `node_version` input to change the desired version. It will be passed to [`nvm install`](https://github.com/nvm-sh/nvm#usage). Valid examples include `16.3.0`, `14`, or `--lts`. Alternatively, create an `.nvmrc` file with the desired version range in your repository. + +## Contributors + +- [tpluscode](https://github.com/tpluscode)