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

How to add personal access tokens as environment variables to a action ? #73

Open
chlbri opened this issue Jan 7, 2023 · 3 comments
Open

Comments

@chlbri
Copy link

chlbri commented Jan 7, 2023

I have a personnel token that helps me to read packages create by my organization.

Capture d'écran 2023-01-07 à 15 07 08 PM

How can I integrate it as env variable to an action.

I try to access it by secrets:
Capture d'écran 2023-01-07 à 15 20 10 PM

But it's not working.

Run pnpm install --no-frozen-lockfile
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:8)
Lockfile is up to date, resolution step is skipped
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:9)
Progress: resolved 1, reused 0, downloaded 0, added 0
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:10)
Packages: +247
[(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:11)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:12)
Packages are hard linked from the content-addressable store to the virtual store.
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:13)
  Content-addressable store is at: /home/runner/setup-pnpm/node_modules/.bin/store/v3
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:14)
  Virtual store is at:             node_modules/.pnpm
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:15)
Progress: resolved 247, reused 0, downloaded 30, added 25
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:16)
Progress: resolved 247, reused 0, downloaded 77, added 72
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:17)
 ERR_PNPM_FETCH_401  GET https://npm.pkg.github.com/download/@chlbri/beme-news1-core/0.1.2/c3a87044cdf2a55d54161c2d3678fd3f1228b828: Unauthorized - 401
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:18)

(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:19)
An authorization header was used: ***
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:20)

(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:21)
These authorization settings were found:
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:22)
@chlbri:registry=https://npm.pkg.github.com/
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:23)
//npm.pkg.github.com/:_authToken=[hidden]
(https://github.com/chlbri/beme-news1-table/actions/runs/3862708222/jobs/6584443508#step:5:24)
Error: Process completed with exit code 1.

Can you help me ?

@juanpicado
Copy link
Member

juanpicado commented Jan 7, 2023

You can try this pnpm/pnpm#3141 (comment)

I copy here the solution adapted

      - name: Set token config
        run: |
          echo "//npm.pkg.github.com/:_authToken=${secrets.NPM_TOKEN}" > .npmrc
          echo "@yourScope=https://npm.pkg.github.com/" >> .npmrc
          echo "_auth=${secrets.NPM_TOKEN}" >> .npmrc
          echo "always-auth=true" >> .npmrc
        env:
          secrets.NPM_TOKEN: ${{secrets.NPM_TOKEN}}
      - name: Install
        run: pnpm install

Keep on mind that pnpm is able to read from .npmrc so this should works fine. If you have troubles you can always increase the logging to see more in detail what is returning the registry.

@jamesarosen
Copy link

@juanpicado that looks like what you'd use to access a private NPM package, not a private GitHub repo.

@KSXGitHub
Copy link
Collaborator

Apologize for late response.

Does this work? https://pnpm.io/npmrc#url_authtoken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants