Reputation: 2514
I have one GitHub Action that is transforming a design tokens json file into a CSS file containing variables. That is working ok.
I have another yml
file that only starts up after the first workflow has finished:
name: Package
# Only trigger, when the transform workflow succeeded
on:
workflow_run:
workflows: ["transform"]
types:
- completed
jobs:
publish-gpr:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
I just want to publish the CSS file as a package on GitHub Packages or NPM.
I am getting the following error:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/
npm ERR! need auth You need to authorize this machine using `npm adduser`
Upvotes: 0
Views: 459
Reputation: 2192
Try adding the publishConfig to your package.json
file:
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
}
Also, please make sure that your package is scoped:
"name": "@<gh-user-or-org>/<repo>"
Make sure that your package-lock.json
is also updated (since the npm ci
command relies on it). For more details, read the Publishing a package.
To publish your package to the regular NPM registry you need to store your npm authentication token as a secret. For example, create a repository secret called NPM_TOKEN
. For more information, see Creating and using encrypted secrets.
To generate an npm token, you need to log in to your npmjs.com account, click your Profile picture > Access Tokens > Generate New Token > Classic Token. Make sure to choose the Automation token type.
After creating a repository secret with the npm token, make sure to update the workflow:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Upvotes: 1