Compare commits

..

29 Commits

Author SHA1 Message Date
ae3937cacb Update authutil.js 2019-08-06 16:39:01 -04:00
40a00ae373 Add tests 2019-08-06 15:27:51 -04:00
f1da8b89e2 Try changes again 2019-08-06 14:46:42 -04:00
869ebd91d5 Remove auth token 2019-08-06 14:25:05 -04:00
d157c73da6 Try just adding auth token 2019-08-06 14:17:51 -04:00
0dfe4cf4d4 Keep in root of repo 2019-08-06 14:14:58 -04:00
4d381b188a Use userconfig and append trailing slash 2019-08-06 14:08:18 -04:00
b9164e8546 Fix the registry string. 2019-08-06 12:23:49 -04:00
c970c05a19 Add single quotes for authString 2019-08-06 12:07:22 -04:00
e7609c8e84 Update authutil.js 2019-08-06 11:52:37 -04:00
ff5ec869e5 Don't export both userconfigs 2019-08-06 11:52:15 -04:00
f20c85e5e5 Fix string interpolation for auth token. 2019-08-06 11:19:12 -04:00
da3e59948e Get auth working for now pending runner changes 2019-08-06 10:58:30 -04:00
3c9d73515f Try exporting blank token 2019-08-06 09:47:51 -04:00
c09ef151f8 Dont always auth 2019-08-06 09:40:13 -04:00
985b557393 npmrc in RUNNER_TEMP 2019-08-06 09:26:34 -04:00
1be350f27e Merge branch 'master' of https://github.com/actions/setup-node into auth 2019-08-05 22:24:44 -04:00
6b65ca8e49 Merge branch 'master' into auth 2019-08-05 21:33:24 -04:00
feb12fe291 new toolkit and scoped registries 2019-08-05 15:18:52 -04:00
a9f1343a9a Add type 2019-08-05 13:15:47 -04:00
920661f1be Feedback 2019-08-05 13:12:37 -04:00
8e12aec29e Update readme 2019-08-05 12:02:15 -04:00
f338d8591f Description 2019-08-05 11:58:24 -04:00
9776256210 Yarn sometimes prefers npmrc, so use same token 2019-08-05 11:57:53 -04:00
287437bd45 Update 2019-08-05 11:51:04 -04:00
dd1cda5071 Update 2019-08-05 11:47:09 -04:00
0930c1111e Update 2019-08-05 11:46:12 -04:00
409b7dfb5b Update 2019-08-05 11:44:04 -04:00
2b9c956517 Updates 2019-08-05 11:35:39 -04:00
6 changed files with 17 additions and 50 deletions

View File

@ -1,9 +1,5 @@
# setup-node # setup-node
<p align="left">
<a href="https://github.com/actions/setup-node"><img alt="GitHub Actions status" src="https://github.com/actions/setup-node/workflows/Main%20workflow/badge.svg"></a>
</p>
This action sets by node environment for use in actions by: This action sets by node environment for use in actions by:
- optionally downloading and caching a version of node - npm by version spec and add to PATH - optionally downloading and caching a version of node - npm by version spec and add to PATH
@ -19,7 +15,7 @@ steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: '10.x' version: '10.x'
- run: npm install - run: npm install
- run: npm test - run: npm test
``` ```
@ -38,50 +34,38 @@ jobs:
- name: Setup node - name: Setup node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node }} version: ${{ matrix.node }}
- run: npm install - run: npm install
- run: npm test - run: npm test
``` ```
Publish to npmjs and GPR with npm: Set up auth with npm:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: '10.x' version: '10.x'
registry-url: 'https://registry.npmjs.org' registry-url: <registry url>
- run: npm install - run: npm install
- run: npm publish - run: npm publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v1
with:
registry-url: 'https://npm.pkg.github.com'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
Publish to npmjs and GPR with yarn: Set up auth with yarn:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: '10.x' version: '10.x'
registry-url: <registry url> registry-url: <registry url>
- run: npm install -g yarn - run: npm install -g yarn
- run: yarn install - run: yarn install
- run: yarn publish - run: yarn publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
- uses: actions/setup-node@v1
with:
registry-url: 'https://npm.pkg.github.com'
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
# License # License

View File

@ -1,17 +1,14 @@
name: 'Setup Node.js environment' name: 'Setup Node.js for use with actions'
description: 'Setup a Node.js environment and add it to the PATH, additionally providing proxy support' description: 'Setup a Node.js environment and add it to the PATH, additionally providing proxy support'
author: 'GitHub' author: 'GitHub'
inputs: inputs:
node-version: version:
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0' description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0, lts'
default: '10.x' default: '10.x'
registry-url: registry-url:
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN' description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN'
scope: scope:
description: 'Optional scope for authenticating against scoped registries' description: 'Optional scope for authenticating against scoped registries'
# Deprecated option, do not use. Will not be supported after October 1, 2019
version:
description: 'Deprecated. Use node-version instead. Will not be supported after October 1, 2019'
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/setup-node.js' main: 'lib/setup-node.js'

View File

@ -30,15 +30,7 @@ function writeRegistryToFile(registryUrl, fileLocation) {
} }
core.debug(`Setting auth in ${fileLocation}`); core.debug(`Setting auth in ${fileLocation}`);
let newContents = ''; let newContents = '';
if (fs.existsSync(fileLocation)) {
const curContents = fs.readFileSync(fileLocation, 'utf8');
curContents.split(os.EOL).forEach((line) => {
// Add current contents unless they are setting the registry
if (!line.toLowerCase().startsWith('registry')) {
newContents += line + os.EOL;
}
});
}
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = scope const registryString = scope

View File

@ -26,10 +26,7 @@ function run() {
// Version is optional. If supplied, install / use from the tool cache // Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc... // If not supplied then task is still used to setup proxy, auth, etc...
// //
let version = core.getInput('version'); const version = core.getInput('version');
if (!version) {
version = core.getInput('node-version');
}
if (version) { if (version) {
// TODO: installer doesn't support proxy // TODO: installer doesn't support proxy
yield installer.getNode(version); yield installer.getNode(version);

View File

@ -17,7 +17,7 @@ export function configAuthentication(registryUrl: string) {
} }
function writeRegistryToFile(registryUrl: string, fileLocation: string) { function writeRegistryToFile(registryUrl: string, fileLocation: string) {
let scope: string = core.getInput('scope'); let scope = core.getInput('scope');
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
scope = github.context.repo.owner; scope = github.context.repo.owner;
} }
@ -37,9 +37,9 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
}); });
} }
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString: string = const authString =
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString: string = scope const registryString = scope
? `${scope}:registry=${registryUrl}` ? `${scope}:registry=${registryUrl}`
: `registry=${registryUrl}`; : `registry=${registryUrl}`;
newContents += `${authString}${os.EOL}${registryString}`; newContents += `${authString}${os.EOL}${registryString}`;

View File

@ -9,10 +9,7 @@ async function run() {
// Version is optional. If supplied, install / use from the tool cache // Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc... // If not supplied then task is still used to setup proxy, auth, etc...
// //
let version = core.getInput('version'); const version = core.getInput('version');
if (!version) {
version = core.getInput('node-version');
}
if (version) { if (version) {
// TODO: installer doesn't support proxy // TODO: installer doesn't support proxy
await installer.getNode(version); await installer.getNode(version);