mirror of
https://gitea.com/actions/setup-node.git
synced 2025-08-29 23:19:13 +08:00
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ae3937cacb | ||
![]() |
40a00ae373 | ||
![]() |
f1da8b89e2 | ||
![]() |
869ebd91d5 | ||
![]() |
d157c73da6 | ||
![]() |
0dfe4cf4d4 | ||
![]() |
4d381b188a | ||
![]() |
b9164e8546 | ||
![]() |
c970c05a19 | ||
![]() |
e7609c8e84 | ||
![]() |
ff5ec869e5 | ||
![]() |
f20c85e5e5 | ||
![]() |
da3e59948e | ||
![]() |
3c9d73515f | ||
![]() |
c09ef151f8 | ||
![]() |
985b557393 | ||
![]() |
1be350f27e | ||
![]() |
0675b87d74 | ||
![]() |
6b65ca8e49 | ||
![]() |
213c968cb9 | ||
![]() |
feb12fe291 | ||
![]() |
a9f1343a9a | ||
![]() |
920661f1be | ||
![]() |
8e12aec29e | ||
![]() |
f338d8591f | ||
![]() |
9776256210 | ||
![]() |
287437bd45 | ||
![]() |
dd1cda5071 | ||
![]() |
0930c1111e | ||
![]() |
409b7dfb5b | ||
![]() |
2b9c956517 |
18
README.md
18
README.md
@@ -39,27 +39,21 @@ jobs:
|
|||||||
- 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:
|
||||||
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
|
||||||
@@ -72,12 +66,6 @@ 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,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
|
||||||
|
@@ -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}`;
|
||||||
|
Reference in New Issue
Block a user