fix(ci): force npm userconfig + whoami gate for publish auth #95
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| publish: | |
| concurrency: | |
| group: publish | |
| cancel-in-progress: false | |
| runs-on: ubuntu-latest | |
| env: | |
| PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18.x' | |
| scope: '@foo-software' | |
| registry-url: 'https://registry.npmjs.org' | |
| always-auth: true | |
| - name: Full Clean (no npm cache) | |
| run: | | |
| rm -rf node_modules | |
| rm -rf packages/*/node_modules | |
| - name: Use stable npm version | |
| run: npm install -g npm@9.9.0 | |
| - name: Install | |
| run: | | |
| npm ci | |
| npm run lerna -- bootstrap --hoist | |
| - name: Show installed type versions | |
| run: | | |
| npm ls @types/node || true | |
| npm ls @jest/types || true | |
| - name: Publish Packages | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| # Force npm to use an explicit userconfig (matches the local workaround that actually publishes) | |
| printf "//registry.npmjs.org/:_authToken=%s\n" "$NPM_TOKEN" > "${GITHUB_WORKSPACE}/.npmrc" | |
| export NPM_CONFIG_USERCONFIG="${GITHUB_WORKSPACE}/.npmrc" | |
| npm whoami | |
| node packages/foo-api-ci-tools/dist/bin/config-git.js | |
| node packages/foo-api-ci-tools/dist/bin/publish-packages.js |