CI Setup & GitHub Package Registry
CI Setup & GitHub Package Registry
myProp uses a GitHub Actions CI workflow for automated builds and tests. The workflow depends on a private npm package (@saas-factory-live/shell) hosted on the GitHub Package Registry. Before CI can run successfully, you must configure an NPM_TOKEN secret in your repository.
Prerequisites
- Access to the
@saas-factory-liveGitHub organisation packages - Permission to create repository secrets (repository admin or owner)
Configuring the NPM_TOKEN secret
-
Create a GitHub Personal Access Token (classic) from your GitHub account:
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token (classic)
- Select the
read:packagesscope - The token must belong to an account that has access to the
@saas-factory-liveorganisation packages - Copy the generated token
-
Add the token as a repository secret:
- Go to your repository → Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
NPM_TOKEN - Value: paste the personal access token from step 1
- Click Add secret
-
Re-run the failing CI workflow (if applicable):
- Go to Actions → CI → [failing run] → Re-run all jobs
How it works
The .npmrc file at the repository root routes all @saas-factory-live scoped packages to the GitHub Package Registry:
@saas-factory-live:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
The CI workflow exposes NPM_TOKEN via NODE_AUTH_TOKEN during the npm install step:
- run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
CI workflow overview
The workflow (.github/workflows/ci.yml) runs on:
- Every push to
main - Every pull request targeting
main - Manual dispatch via the GitHub Actions UI
Steps:
- Checkout the repository
- Set up Node.js 20 with GitHub Package Registry authentication
npm install— installs all dependencies including private packagesnpm run build— compiles the projectnpm test— runs the test suite
Required environment variables for CI
The following environment variables are pre-configured in the CI workflow with dummy values for build and test purposes:
| Variable | CI Value |
|---|---|
LETMC_API_KEY | ci_dummy_letmc_key_for_build |
LETMC_API_BASE_URL | https://live-api.letmc.com |
NEXTAUTH_SECRET | test-secret-for-ci |
NEXTAUTH_URL | http://localhost:3000 |
DATABASE_URL | postgresql://dummy:dummy@localhost:5432/dummy |
These values are sufficient for compilation and unit tests. They are not used for real API calls.
Troubleshooting
401 Unauthorized from npm.pkg.github.com
npm error code E401
npm error 401 Unauthorized - GET https://npm.pkg.github.com/@saas-factory-live/shell
npm error authentication token not provided
Cause: The NPM_TOKEN secret is missing or has not been saved to the repository.
Fix: Follow the Configuring the NPM_TOKEN secret steps above.
Token has correct scope but still fails
Verify that the GitHub account that generated the token is a member of the @saas-factory-live organisation and has at least read access to the relevant packages.