# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Publish NPM Package

on: 
  workflow_dispatch:
    inputs:
      packageDir:
        description: 'Project directory'
        required: true
        default: 'schema'

defaults:
  run:
    shell: bash
    working-directory: ${{ github.event.inputs.packageDir }}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16
      - run: npm ci
      - run: npm test

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: codfish/semantic-release-action@v1
        name: Semantic Release Action
        with:
          branches: |
            ['master', 'main']
    env:
      GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
      GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Add manual trigger for releasing packages
ci(Actions): Add manual trigger for releasing packages