Skip to content

CD - Deploy Core Package to npm #5

CD - Deploy Core Package to npm

CD - Deploy Core Package to npm #5

name: "CD - Deploy Core Package to npm"
on:
workflow_dispatch:
inputs:
tag:
description: "Tag to deploy"
required: true
type: string
jobs:
create-release-from-tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
needs: create-release-from-tag
runs-on: ubuntu-latest
environment:
name: npm-core
url: https://www.npmjs.com/package/@common-grants/core
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: ./lib/core
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
# Setup .npmrc file to publish to npm
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: https://registry.npmjs.org
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.18.3
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run checks
run: pnpm --filter @common-grants/core run checks
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
- name: Notify completion
run: |
echo "Core package deployed to npm"
echo "Tag: ${{ github.event.inputs.tag }}"