Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] The action fails to authenticate to private npm registry #379

Open
serpro69 opened this issue Jun 4, 2024 · 3 comments
Open

[BUG] The action fails to authenticate to private npm registry #379

serpro69 opened this issue Jun 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@serpro69
Copy link

serpro69 commented Jun 4, 2024

Action config

This is a slightly modified (from default generated) workflow that I have:

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
on:
  push:
    branches:
      - develop
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 18
          registry-url: "https://npm.pkg.github.com"
          scope: "@org-name"
          always-auth: true
      - run: npm ci && npm run build
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: ${{ secrets.GITHUB_TOKEN }}
          firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_FIREBASE_SANDBOX_425310 }}
          channelId: live
          projectId: firebase-sandbox-425310
        env:
          FIREBASE_CLI_EXPERIMENTS: webframeworks,pintags
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Error message

Firebase deployment fails with nnpm ERR! 401 Unauthorized - GET https://npm.pkg.github.com/download/@org-name/app-components-frontend/0.18.33/233b5141a9f47e0a5863ebb4cd714b82c4c87100 - authentication token not provided

Expected behavior

While npm ci works fine because it uses an .npmrc file generated by the setup-node action, firebase hosting deploy action doesn't seem to be picking that up.

I've tried to find something in the docs of either firebase tools or the action, but didn't find anything that would help me resolve this.

Actual behavior

Auth to npm registry fails and hence deployment fails

@serpro69 serpro69 added the bug Something isn't working label Jun 4, 2024
@serpro69
Copy link
Author

serpro69 commented Jun 4, 2024

Found firebase/firebase-tools#5936 , could be related? I guess this needs to be fixed in firebase-tools
Still, maybe there's something that the action can do to help here? Like, temporary copy an .npmrc file with an embedded token? (I think I'll try to do this "manually" now and see how that goes)

@jasonmit
Copy link

@serpro69 I am running into this same issue, did you ever discover a workaround?

@serpro69
Copy link
Author

Hi @jasonmit ,
As far as I understood, this is a firebase(-tooling) issue, not an issue with this action (but I kept this one open just to have the maintainers confirm that; or maybe add some support from the action side, if possible)
The only current workaround I know of is to hardcode the token in the .npmrc file. Regular firebase hosting doesn't seem to support environment variables (The new apphosting seems to , but we're not using that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants