# 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 to GitHub

on:
  repository_dispatch:
    types: [commit-change]

jobs:
  publish-github:
      runs-on: ubuntu-latest
      permissions:
        packages: write
        contents: read
      steps:
        - uses: actions/checkout@v4
          with:
            ref: ${{ github.event.client_payload.tag_name }}
    
        - uses: actions/setup-node@v4
          with:
            node-version: '20.x'
            registry-url: https://npm.pkg.github.com/
        - run: npm pkg set name="@${{ github.repository_owner }}/${{ github.event.repository.name }}"
        - run: npm ci
        - run: npm publish --registry=https://npm.pkg.github.com
          env:
            NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}