publish npm packages #3559
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 npm packages | |
| env: | |
| NX_CLOUD_ACCESS_TOKEN: ${{ vars.NX_CLOUD_ACCESS_TOKEN }} | |
| on: | |
| workflow_dispatch: | |
| # trigger this workflow when the CI workflow is completed | |
| workflow_run: | |
| workflows: ["Continuous Integration"] | |
| branches: [main] | |
| types: | |
| - completed | |
| jobs: | |
| publish: | |
| # Allow manual runs, otherwise require CI success on main | |
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| environment: production | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v3 | |
| - name: Setup Pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js 22 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 22 | |
| registry-url: "https://registry.npmjs.org" | |
| cache: "pnpm" | |
| # Conditional steps based on the check | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile | |
| - run: pnpm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
| - name: Install Doppler CLI for env variables | |
| uses: dopplerhq/cli-action@v2 | |
| - name: Build | |
| run: doppler run -- pnpm build | |
| env: | |
| DOPPLER_TOKEN: ${{ secrets.DOPPLER_PRODUCTION_ENV_TOKEN }} | |
| - name: Publish packages | |
| run: pnpm exec changeset publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} |