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 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 ." } diff --git a/Dockerfile b/Dockerfile index dfeec25..aa01d43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM node:10-slim +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 " diff --git a/README.md b/README.md index 2316394..f13845b 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,8 @@ -# GitHub Actions 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 and github.com/actions/setup-node. -## Usage - -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" -} - -action "Publish" { - needs = "Test" - 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_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`: - -```hcl -action "Publish" { - uses = "actions/npm@master" - args = "publish --access public" - env = { - NPM_REGISTRY_URL = "someOtherRegistry.someDomain.net" - } - secrets = ["NPM_TOKEN"] -} -``` +For feature requests and feedback please head over to the community forum https://github.community/t5/GitHub-Actions/bd-p/actions. ## License diff --git a/entrypoint.sh b/entrypoint.sh index efbdfa5..18e6a1b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,10 +5,20 @@ 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}" + 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 - echo "//${NPM_REGISTRY_URL-registry.npmjs.org}/:_authToken=$NPM_AUTH_TOKEN" > "$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 +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 $*" diff --git a/test/entrypoint.bats b/test/entrypoint.bats index 319c8a7..e53cc00 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=https://registry.npmjs.org" ] } @test "registry can be overridden" { @@ -27,5 +29,20 @@ 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=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" ] }