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