Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to install node cli #2

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8c21136
fix: default registry should be set to NPM_REGISTRY_URL
Nov 3, 2018
33871a7
Merge pull request #3 from bcoe/fix-registry-url
swinton Nov 5, 2018
53ecaa5
Update example to only publish for a "tag push"
swinton Nov 5, 2018
b744826
Fix incorrect secret name in README usage example
simonplend Nov 29, 2018
6309cd9
Merge pull request #7 from simonplend/readme-fix-usage-example
nickvanw Nov 30, 2018
9d6b6b0
Changed NPM tag 10-slim to 10.
Dec 11, 2018
c555744
Merge pull request #4 from actions/use-tag-filter
swinton Dec 18, 2018
e7aaefe
Fix readme title
Dec 19, 2018
8695ddf
fix entrypoint tests
hfaulds Jan 17, 2019
98e6dc1
observeshell linting rules
hfaulds Jan 17, 2019
ecd6867
add integration test
hfaulds Jan 17, 2019
de7a370
Merge pull request #19 from actions/hfaulds/testfix
hfaulds Jan 17, 2019
6c36ec8
Bump action version
hfaulds Jan 28, 2019
3c83327
Merge pull request #14 from sweetpalma/patch-1
hfaulds Jan 28, 2019
02ee919
Add a CODEOWNERS file to streamline review.
parkr Feb 9, 2019
4633da3
Merge pull request #23 from actions/codeowners
parkr Feb 9, 2019
f6571dd
Adds support for the NPM_STRICT_SSL environment variable to allow con…
Phanatic Feb 11, 2019
83fb0f9
fix errant tab
Feb 14, 2019
59b64a5
Merge pull request #24 from Phanatic/support-insecure-registry
nickvanw Feb 14, 2019
f11f0a3
Update README.md
chrispat Sep 26, 2019
a9b1f30
Update README.md
chrispat Oct 8, 2019
3353bd1
Add deprecation warning
chrispat Oct 8, 2019
dc94876
Update README.md
chrispat Oct 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @actions/reviewers
7 changes: 6 additions & 1 deletion .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
Expand Down
57 changes: 3 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*"
21 changes: 19 additions & 2 deletions test/entrypoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" ]
}