Publish NPM package #153
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
# Brief: Publish database branch as NPM package post successful testing | |
# Note: Must be run on default branch | |
# Ref: https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-nodejs-packages | |
name: Publish NPM package | |
on: | |
workflow_run: # Run whenever the Test workflow completes | |
workflows: [Test] | |
types: [completed] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
if: github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: Check out database branch | |
uses: actions/checkout@v4 | |
with: | |
ref: database | |
- name: Set up Node runtime and .npmrc | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
check-latest: false | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish # Only if not up-to-date | |
run: | | |
if [ $(scripts/get-version.sh) != $(scripts/latest-version-npm.sh) ]; then | |
npm publish | |
else | |
echo 'Up-to-date. Nothing new to publish.' | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |