Skip to content

Commit abf316b

Browse files
author
niuweili
committed
debug NPM_TOKEN
1 parent d483ba4 commit abf316b

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

.github/workflows/deploy-auto.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
OSS_SECRET_KEY: ${{ secrets.OSS_SECRET_KEY }}
4646

4747
publish-npm:
48-
needs: deploy-prod
48+
# needs: deploy-prod
4949
runs-on: ubuntu-latest
5050
steps:
5151
- name: Checkout code
@@ -60,11 +60,6 @@ jobs:
6060
- name: Install dependencies
6161
run: yarn
6262

63-
- name: Debug NPM token
64-
run: |
65-
echo "Token prefix: ${NODE_AUTH_TOKEN:0:4}..."
66-
npm whoami
67-
6863
- name: Publish to NPM
6964
run: node ./scripts/deploy/publish-npm.js
7065
env:

scripts/deploy/publish-npm.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ const fs = require('fs')
22
const { printLog, runMain } = require('../lib/executionUtils')
33
const { command } = require('../lib/command')
44
const { getNpmToken } = require('../lib/secrets')
5+
const dotenv = require('dotenv')
6+
dotenv.config()
57

68
runMain(() => {
79
printLog('Building the project')
810
command`yarn build`.withEnvironment({ BUILD_MODE: 'release' }).run()
9-
11+
if (!process.env.NPM_TOKEN) {
12+
throw new Error('NPM_TOKEN is not set')
13+
}
1014
printLog('Publishing')
1115
// eslint-disable-next-line no-template-curly-in-string
12-
// fs.writeFileSync('.npmrc', '//registry.npmjs.org/:_authToken=${NPM_TOKEN}')
13-
command`yarn lerna publish from-package --yes`.withEnvironment({ NPM_TOKEN: getNpmToken() }).run()
16+
fs.writeFileSync('.npmrc', `//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`)
17+
command`yarn lerna publish from-package --yes`.withEnvironment({ NPM_TOKEN: process.env.NPM_TOKEN }).run()
1418
})

scripts/lib/secrets.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
const { command } = require('../lib/command')
2-
const dotenv = require('dotenv')
3-
4-
dotenv.config()
52

63
function getGithubDeployKey() {
74
return getSecretKey('ci.browser-sdk.github_deploy_key')
@@ -30,8 +27,7 @@ function getTelemetryOrgApplicationKey(site) {
3027
}
3128

3229
function getNpmToken() {
33-
// return getSecretKey('ci.browser-sdk.npm_token')
34-
return process.env.NPM_TOKEN || ''
30+
return getSecretKey('ci.browser-sdk.npm_token')
3531
}
3632

3733
function getChromeWebStoreClientId() {

0 commit comments

Comments
 (0)