denoland / denoland/deploy_feedback

401 Unauthorized when using a private package (on github registry)

Open
#831 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
79
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Version: Deno 2.2.3
x-deno-ray: fd06651086befa7f2afe627adc6fe5df

I looked the docs and search a lot, but couldn't find any solution for this issue:

I'm running the build step creating the .npmrc file
Currently the `Build Step` works well. But the deploy fails with the error bellow:
`Error: The deployment failed: HTTP status client error (401 Unauthorized) for url (https://npm.pkg.github.com/@%2fshared-lib)`

Note: I tried with `permissions.package: read` and `permissions.package: write` usong the `${{secrets.GITHUB_TOKEN}}` but haven't worked since the package is outside the repo so I changed to use a PAT

Part of my github actions file:
```yaml
jobs:
deploy:
name: Deploy
environment: Production
runs-on: ubuntu-latest

permissions:
packages: write # Needed to install private packages
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

....
steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.2.3

- name: Build step
run: |
cd backend/deno
echo "@:registry=https://npm.pkg.github.com/" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GH_ACCESS_TOKEN }}" >> .npmrc
echo "Caching the index.ts" && deno cache index.ts --allow-import
echo "Running the build" && deno task build --environment production

- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: ""
entrypoint: "index.ts" # 📝 Update the entrypoint
root: "./backend/deno" # 📝 Update the root
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the GitHub Actions workflow, especially the permissions block, generated .npmrc, and the denoland/deployctl@v1 step. Compare the successful build-time package access with the deploy-time environment and determine what prevents the private GitHub package from being fetched; done means deployment completes without the 401 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, github-actions
Domain
authentication, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.