mirror of
https://gitea.com/actions/setup-node.git
synced 2025-08-16 16:56:03 +08: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
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
Set up auth with npm:
|
Publish to npmjs and GPR 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:
|
||||||
version: '10.x'
|
version: '10.x'
|
||||||
registry-url: <registry url>
|
registry-url: 'https://registry.npmjs.org'
|
||||||
- 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 }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Set up auth with yarn:
|
Publish to npmjs and GPR with yarn:
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
@@ -66,6 +72,12 @@ steps:
|
|||||||
- 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
|
||||||
|
@@ -30,7 +30,15 @@ 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
|
||||||
|
@@ -17,7 +17,7 @@ export function configAuthentication(registryUrl: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function writeRegistryToFile(registryUrl: string, fileLocation: 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) {
|
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 =
|
const authString: string =
|
||||||
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||||
const registryString = scope
|
const registryString: string = scope
|
||||||
? `${scope}:registry=${registryUrl}`
|
? `${scope}:registry=${registryUrl}`
|
||||||
: `registry=${registryUrl}`;
|
: `registry=${registryUrl}`;
|
||||||
newContents += `${authString}${os.EOL}${registryString}`;
|
newContents += `${authString}${os.EOL}${registryString}`;
|
||||||
|
Reference in New Issue
Block a user