fix(ci): Use .npmrc for registry authentication in Gitea workflow and add conditional npmjs publish
This commit is contained in:
		| @@ -71,15 +71,19 @@ jobs: | ||||
|           # Extract server host from GITHUB_SERVER_URL (remove https://) | ||||
|           GITEA_HOST="${GITHUB_SERVER_URL#https://}" | ||||
|           GITEA_REGISTRY="$GITHUB_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/npm/" | ||||
|           # Configure Gitea npm registry | ||||
|           npm config set @${GITHUB_REPOSITORY_OWNER}:registry "$GITEA_REGISTRY" | ||||
|           npm config set "//${GITEA_HOST}/api/packages/${GITHUB_REPOSITORY_OWNER}/npm/:_authToken" "$GITEA_TOKEN" | ||||
|  | ||||
|           # Create .npmrc for Gitea authentication | ||||
|           echo "@${GITHUB_REPOSITORY_OWNER}:registry=${GITEA_REGISTRY}" > .npmrc | ||||
|           echo "//${GITEA_HOST}/api/packages/${GITHUB_REPOSITORY_OWNER}/npm/:_authToken=${GITEA_TOKEN}" >> .npmrc | ||||
|  | ||||
|           # Publish to Gitea | ||||
|           pnpm publish --no-git-checks | ||||
|  | ||||
|           # Conditionally publish to npmjs.org if token exists | ||||
|           if [ -n "$NPMCI_TOKEN_NPM" ]; then | ||||
|             npm config set registry https://registry.npmjs.org | ||||
|             npm config set //registry.npmjs.org/:_authToken "$NPMCI_TOKEN_NPM" | ||||
|             # Update .npmrc for npmjs.org | ||||
|             echo "registry=https://registry.npmjs.org/" > .npmrc | ||||
|             echo "//registry.npmjs.org/:_authToken=${NPMCI_TOKEN_NPM}" >> .npmrc | ||||
|             pnpm publish --no-git-checks | ||||
|           fi | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user