You've already forked setup-node
mirror of
https://github.com/actions/setup-node.git
synced 2025-08-07 06:04:38 +07:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
5273d0df9c | |||
fc9ff49b90 | |||
552489ce4b | |||
401832ee64 | |||
b0d4a002ac | |||
ea546c14bf |
18
README.md
18
README.md
@ -39,21 +39,27 @@ jobs:
|
||||
- run: npm test
|
||||
```
|
||||
|
||||
Set up auth with npm:
|
||||
Publish to npmjs and GPR with npm:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
version: '10.x'
|
||||
registry-url: <registry url>
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: npm install
|
||||
- run: npm publish
|
||||
env:
|
||||
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 }}
|
||||
```
|
||||
|
||||
Set up auth with yarn:
|
||||
Publish to npmjs and GPR with yarn:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
@ -66,6 +72,12 @@ steps:
|
||||
- run: yarn publish
|
||||
env:
|
||||
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
|
||||
|
@ -30,7 +30,15 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
||||
}
|
||||
core.debug(`Setting auth in ${fileLocation}`);
|
||||
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.
|
||||
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||
const registryString = scope
|
||||
|
@ -17,7 +17,7 @@ export function configAuthentication(registryUrl: string) {
|
||||
}
|
||||
|
||||
function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
||||
let scope = core.getInput('scope');
|
||||
let scope: string = core.getInput('scope');
|
||||
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
|
||||
scope = github.context.repo.owner;
|
||||
}
|
||||
@ -37,9 +37,9 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
||||
});
|
||||
}
|
||||
// Remove http: or https: from front of registry.
|
||||
const authString =
|
||||
const authString: string =
|
||||
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||
const registryString = scope
|
||||
const registryString: string = scope
|
||||
? `${scope}:registry=${registryUrl}`
|
||||
: `registry=${registryUrl}`;
|
||||
newContents += `${authString}${os.EOL}${registryString}`;
|
||||
|
Reference in New Issue
Block a user