From 8c21136f88a3195537b6fa693c6d71fa16e7a6cc Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 3 Nov 2018 15:25:58 -0700 Subject: [PATCH 01/16] fix: default registry should be set to NPM_REGISTRY_URL --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index efbdfa5..81e8e33 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,9 +5,10 @@ set -e if [ -n "$NPM_AUTH_TOKEN" ]; then # Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG-"$HOME/.npmrc"}" + NPM_REGISTRY_URL="${NPM_REGISTRY_URL-registry.npmjs.org}" # Allow registry.npmjs.org to be overridden with an environment variable - echo "//${NPM_REGISTRY_URL-registry.npmjs.org}/:_authToken=$NPM_AUTH_TOKEN" > "$NPM_CONFIG_USERCONFIG" + printf "//$NPM_REGISTRY_URL/:_authToken=$NPM_AUTH_TOKEN\nregistry=$NPM_REGISTRY_URL" > "$NPM_CONFIG_USERCONFIG" chmod 0600 "$NPM_CONFIG_USERCONFIG" fi From 53ecaa558a60c42e825b8afca8abeda0b7aa0870 Mon Sep 17 00:00:00 2001 From: Steve Winton Date: Mon, 5 Nov 2018 17:38:09 -0600 Subject: [PATCH 02/16] Update example to only publish for a "tag push" --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2316394..bd51b3a 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,15 @@ action "Test" { args = "test" } -action "Publish" { +# Filter for a new tag +action "Tag" { needs = "Test" + uses = "actions/bin/filter@master" + args = "tag" +} + +action "Publish" { + needs = "Tag" uses = "actions/npm@master" args = "publish --access public" secrets = ["NPM_AUTH_TOKEN"] From b7448260131e28baa2a79fd546db683cbffd1f20 Mon Sep 17 00:00:00 2001 From: Simon Plenderleith Date: Thu, 29 Nov 2018 09:59:56 +0000 Subject: [PATCH 03/16] Fix incorrect secret name in README usage example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2316394..ff507ea 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ action "Publish" { env = { NPM_REGISTRY_URL = "someOtherRegistry.someDomain.net" } - secrets = ["NPM_TOKEN"] + secrets = ["NPM_AUTH_TOKEN"] } ``` From 9d6b6b008f891e78177b4e422a1350e8326fbc5e Mon Sep 17 00:00:00 2001 From: Paul Marlow Date: Tue, 11 Dec 2018 18:59:40 +0200 Subject: [PATCH 04/16] Changed NPM tag 10-slim to 10. That would help running tools like `lerna`: https://github.com/actions/npm/issues/8 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dfeec25..7b81fca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10-slim +FROM node:10 LABEL version="1.0.0" LABEL repository="http://github.com/actions/npm" From e7aaefed7c9f2e83d493ff810f17fa5ccd7ed437 Mon Sep 17 00:00:00 2001 From: Mike Coutermarsh Date: Wed, 19 Dec 2018 12:31:32 -0800 Subject: [PATCH 05/16] Fix readme title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d49ed9..97b7b10 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# GitHub Actions for NPM +# GitHub Action for NPM This Action for [npm](https://www.npmjs.com/) enables arbitrary actions with the `npm` command-line client, including testing packages and publishing to a registry. From 8695ddf45f75884deadbbfa4c97f053124855567 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Thu, 17 Jan 2019 14:53:39 +0000 Subject: [PATCH 06/16] fix entrypoint tests --- test/entrypoint.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/entrypoint.bats b/test/entrypoint.bats index 319c8a7..4e0e2d0 100644 --- a/test/entrypoint.bats +++ b/test/entrypoint.bats @@ -18,7 +18,9 @@ function setup() { export NPM_AUTH_TOKEN=NPM_AUTH_TOKEN run $GITHUB_WORKSPACE/entrypoint.sh help [ "$status" -eq 0 ] - [ "$(cat $NPM_CONFIG_USERCONFIG)" = "//registry.npmjs.org/:_authToken=NPM_AUTH_TOKEN" ] + run cat $NPM_CONFIG_USERCONFIG + [ "${lines[0]}" = "//registry.npmjs.org/:_authToken=NPM_AUTH_TOKEN" ] + [ "${lines[1]}" = "registry=registry.npmjs.org" ] } @test "registry can be overridden" { @@ -27,5 +29,7 @@ function setup() { export NPM_AUTH_TOKEN=NPM_AUTH_TOKEN run $GITHUB_WORKSPACE/entrypoint.sh help [ "$status" -eq 0 ] - [ "$(cat $NPM_CONFIG_USERCONFIG)" = "//someOtherRegistry.someDomain.net/:_authToken=NPM_AUTH_TOKEN" ] + run cat $NPM_CONFIG_USERCONFIG + [ "${lines[0]}" = "//someOtherRegistry.someDomain.net/:_authToken=NPM_AUTH_TOKEN" ] + [ "${lines[1]}" = "registry=someOtherRegistry.someDomain.net" ] } From 98e6dc1f25e14ff60a2abb16cc85fcdef7b4815e Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Thu, 17 Jan 2019 14:53:53 +0000 Subject: [PATCH 07/16] =?UTF-8?q?observe=EF=9C=82shell=20linting=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 81e8e33..2c583ce 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,7 +8,7 @@ if [ -n "$NPM_AUTH_TOKEN" ]; then NPM_REGISTRY_URL="${NPM_REGISTRY_URL-registry.npmjs.org}" # Allow registry.npmjs.org to be overridden with an environment variable - printf "//$NPM_REGISTRY_URL/:_authToken=$NPM_AUTH_TOKEN\nregistry=$NPM_REGISTRY_URL" > "$NPM_CONFIG_USERCONFIG" + printf "//%s/:_authToken=%s\\nregistry=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "$NPM_REGISTRY_URL" > "$NPM_CONFIG_USERCONFIG" chmod 0600 "$NPM_CONFIG_USERCONFIG" fi From ecd68671e4d9cb53d02afa12d000ab3d630a9498 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Thu, 17 Jan 2019 15:54:13 +0000 Subject: [PATCH 08/16] add integration test --- .github/main.workflow | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/main.workflow b/.github/main.workflow index 77bc516..d33b7eb 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -13,13 +13,18 @@ action "Test" { args = "test/*.bats" } +action "Integration Test" { + uses = "./" + args = "version" +} + action "Docker Lint" { uses = "docker://replicated/dockerfilelint" args = ["Dockerfile"] } action "Build" { - needs = ["Shell Lint", "Test", "Docker Lint"] + needs = ["Shell Lint", "Test", "Integration Test", "Docker Lint"] uses = "actions/docker/cli@master" args = "build -t npm ." } From 6c36ec8beefa3c439fae2672beea88c2f56b6038 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Mon, 28 Jan 2019 14:15:21 +0000 Subject: [PATCH 09/16] Bump action version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7b81fca..aa01d43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:10 -LABEL version="1.0.0" +LABEL version="2.0.0" LABEL repository="http://github.com/actions/npm" LABEL homepage="http://github.com/actions/npm" LABEL maintainer="GitHub Actions " From 02ee919b37f0ba1c2e5e98a275c762525a8da540 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 9 Feb 2019 13:20:19 -0500 Subject: [PATCH 10/16] Add a CODEOWNERS file to streamline review. --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..12d62c4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @actions/reviewers From f6571ddd46bb2ac9f9456df63e8d7e131ef3195f Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 11 Feb 2019 10:22:26 -0600 Subject: [PATCH 11/16] Adds support for the NPM_STRICT_SSL environment variable to allow connecting to insecure npm registries from within an action. --- README.md | 17 ++++++++++++++++- entrypoint.sh | 9 ++++++++- test/entrypoint.bats | 17 +++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 97b7b10..9870bd0 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,12 @@ action "Publish" { ### Environment variables * `NPM_REGISTRY_URL` - **Optional**. To specify a registry to authenticate with. Defaults to `registry.npmjs.org` +* `NPM_STRICT_SSL` - **Optional**. Specify false if your registry is insecure and uses the `http` protocol. Defaults to `true` * `NPM_CONFIG_USERCONFIG` - **Optional**. To specify a non-default per-user configuration file. Defaults to `$HOME/.npmrc` ([more info](https://docs.npmjs.com/misc/config#npmrc-files)) #### Example -To authenticate with, and publish to, a registry other than `registry.npmjs.org`: +To authenticate with, and publish to, a secure registry other than `registry.npmjs.org`: ```hcl action "Publish" { @@ -62,6 +63,20 @@ action "Publish" { } ``` + +To authenticate with, and publish to, an insecure registry other than `registry.npmjs.org`: + +```hcl +action "Publish" { + uses = "actions/npm@master" + args = "publish --access public" + env = { + NPM_REGISTRY_URL = "my.local.registry" + NPM_STRICT_SSL = "false" + } + secrets = ["NPM_AUTH_TOKEN"] +} +``` ## License The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). diff --git a/entrypoint.sh b/entrypoint.sh index 2c583ce..43b7ba9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,9 +6,16 @@ if [ -n "$NPM_AUTH_TOKEN" ]; then # Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG-"$HOME/.npmrc"}" NPM_REGISTRY_URL="${NPM_REGISTRY_URL-registry.npmjs.org}" + NPM_STRICT_SSL="${NPM_STRICT_SSL-true}" + NPM_REGISTRY_SCHEME="https" + if ! $NPM_STRICT_SSL + then + NPM_REGISTRY_SCHEME="http" + fi # Allow registry.npmjs.org to be overridden with an environment variable - printf "//%s/:_authToken=%s\\nregistry=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "$NPM_REGISTRY_URL" > "$NPM_CONFIG_USERCONFIG" + printf "//%s/:_authToken=%s\\nregistry=%s\\nstrict-ssl=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "${NPM_REGISTRY_SCHEME}://$NPM_REGISTRY_URL" "${NPM_STRICT_SSL}" > "$NPM_CONFIG_USERCONFIG" + chmod 0600 "$NPM_CONFIG_USERCONFIG" fi diff --git a/test/entrypoint.bats b/test/entrypoint.bats index 4e0e2d0..e53cc00 100644 --- a/test/entrypoint.bats +++ b/test/entrypoint.bats @@ -20,7 +20,7 @@ function setup() { [ "$status" -eq 0 ] run cat $NPM_CONFIG_USERCONFIG [ "${lines[0]}" = "//registry.npmjs.org/:_authToken=NPM_AUTH_TOKEN" ] - [ "${lines[1]}" = "registry=registry.npmjs.org" ] + [ "${lines[1]}" = "registry=https://registry.npmjs.org" ] } @test "registry can be overridden" { @@ -31,5 +31,18 @@ function setup() { [ "$status" -eq 0 ] run cat $NPM_CONFIG_USERCONFIG [ "${lines[0]}" = "//someOtherRegistry.someDomain.net/:_authToken=NPM_AUTH_TOKEN" ] - [ "${lines[1]}" = "registry=someOtherRegistry.someDomain.net" ] + [ "${lines[1]}" = "registry=https://someOtherRegistry.someDomain.net" ] +} + +@test "supports insecure registry" { + export NPM_CONFIG_USERCONFIG=$( mktemp ) + export NPM_STRICT_SSL=false + export NPM_REGISTRY_URL=someOtherRegistry.someDomain.net + export NPM_AUTH_TOKEN=NPM_AUTH_TOKEN + run $GITHUB_WORKSPACE/entrypoint.sh help + [ "$status" -eq 0 ] + run cat $NPM_CONFIG_USERCONFIG + [ "${lines[0]}" = "//someOtherRegistry.someDomain.net/:_authToken=NPM_AUTH_TOKEN" ] + [ "${lines[1]}" = "registry=http://someOtherRegistry.someDomain.net" ] + [ "${lines[2]}" = "strict-ssl=false" ] } From 83fb0f9e17fdf27df69b2ae619e624d9bd8de52c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 14 Feb 2019 14:44:05 -0600 Subject: [PATCH 12/16] fix errant tab --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 43b7ba9..656c7ea 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,7 +10,7 @@ if [ -n "$NPM_AUTH_TOKEN" ]; then NPM_REGISTRY_SCHEME="https" if ! $NPM_STRICT_SSL then - NPM_REGISTRY_SCHEME="http" + NPM_REGISTRY_SCHEME="http" fi # Allow registry.npmjs.org to be overridden with an environment variable From f11f0a33bb81074e6448ed3737cbc6ca4e1318d2 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Wed, 25 Sep 2019 21:06:13 -0400 Subject: [PATCH 13/16] Update README.md --- README.md | 79 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 9870bd0..ab3ca7d 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,9 @@ -# GitHub Action for NPM +# Important -This Action for [npm](https://www.npmjs.com/) enables arbitrary actions with the `npm` command-line client, including testing packages and publishing to a registry. +This action is deprecated in favor of using the [`run`](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun) script step in the new YAML language to run the various cli tools represented by these actions. -## Usage +For feature requests and feedback please head over to the community forum. https://github.community/t5/GitHub-Actions/bd-p/actions -An example workflow to build, test, and publish an npm package to the default public registry follows: - -```hcl -workflow "Build, Test, and Publish" { - on = "push" - resolves = ["Publish"] -} - -action "Build" { - uses = "actions/npm@master" - args = "install" -} - -action "Test" { - needs = "Build" - uses = "actions/npm@master" - args = "test" -} - -# Filter for a new tag -action "Tag" { - needs = "Test" - uses = "actions/bin/filter@master" - args = "tag" -} - -action "Publish" { - needs = "Tag" - uses = "actions/npm@master" - args = "publish --access public" - secrets = ["NPM_AUTH_TOKEN"] -} -``` - -### Secrets - -* `NPM_AUTH_TOKEN` - **Optional**. The token to use for authentication with the npm registry. Required for `npm publish` ([more info](https://docs.npmjs.com/getting-started/working_with_tokens)) - -### Environment variables - -* `NPM_REGISTRY_URL` - **Optional**. To specify a registry to authenticate with. Defaults to `registry.npmjs.org` -* `NPM_STRICT_SSL` - **Optional**. Specify false if your registry is insecure and uses the `http` protocol. Defaults to `true` -* `NPM_CONFIG_USERCONFIG` - **Optional**. To specify a non-default per-user configuration file. Defaults to `$HOME/.npmrc` ([more info](https://docs.npmjs.com/misc/config#npmrc-files)) - -#### Example - -To authenticate with, and publish to, a secure registry other than `registry.npmjs.org`: - -```hcl -action "Publish" { - uses = "actions/npm@master" - args = "publish --access public" - env = { - NPM_REGISTRY_URL = "someOtherRegistry.someDomain.net" - } - secrets = ["NPM_AUTH_TOKEN"] -} -``` - - -To authenticate with, and publish to, an insecure registry other than `registry.npmjs.org`: - -```hcl -action "Publish" { - uses = "actions/npm@master" - args = "publish --access public" - env = { - NPM_REGISTRY_URL = "my.local.registry" - NPM_STRICT_SSL = "false" - } - secrets = ["NPM_AUTH_TOKEN"] -} -``` ## License The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). From a9b1f30984cb18f0698e878774e3cdae3baa0a40 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Tue, 8 Oct 2019 09:42:54 -0400 Subject: [PATCH 14/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab3ca7d..54b4d96 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This action is deprecated in favor of using the [`run`](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun) script step in the new YAML language to run the various cli tools represented by these actions. -For feature requests and feedback please head over to the community forum. https://github.community/t5/GitHub-Actions/bd-p/actions +For feature requests and feedback please head over to the community forum https://github.community/t5/GitHub-Actions/bd-p/actions. ## License From 3353bd1e04843eae63a3cf0d865be73dec81487d Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Tue, 8 Oct 2019 10:10:33 -0400 Subject: [PATCH 15/16] Add deprecation warning --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 656c7ea..18e6a1b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,4 +19,6 @@ if [ -n "$NPM_AUTH_TOKEN" ]; then chmod 0600 "$NPM_CONFIG_USERCONFIG" fi +echo "##[warning] This actions has been deprecated in favor of github.com/actions/setup-node. This repo has been archived and will be made private on 10/15/2019" + sh -c "npm $*" From dc94876301329c14059c51aa98944e9b4adcdd52 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Tue, 8 Oct 2019 10:11:20 -0400 Subject: [PATCH 16/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54b4d96..f13845b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Important -This action is deprecated in favor of using the [`run`](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun) script step in the new YAML language to run the various cli tools represented by these actions. +This action is deprecated in favor of using the [`run`](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun) script step and github.com/actions/setup-node. For feature requests and feedback please head over to the community forum https://github.community/t5/GitHub-Actions/bd-p/actions.