# 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://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Publish Packages
on:
  push:
    branches:
      - strat-2059

jobs:
  publish:
    if: startsWith(github.event.head_commit.message, 'Publish') == true
    runs-on: ubuntu-20.04
      
    steps:
      - uses: actions/checkout@v3

      - name: Use Node.js 14.x
        uses: actions/setup-node@v3
        with:
          node-version: 14.x
          registry-url: 'https://registry.npmjs.org'

      - name: Install Dependencies
        run: npm ci 

      - name: Fetch Latest Tags
        run: |
          git fetch --tags

      - name: Set NPM Token
        run: |
          npm set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_PUBLISH_TOKEN }}
          npm whoami

      - name: Publish
        run: |
          npm publish
