name: Pathfinder changelog

on:
  workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
  # The concurrency group contains the workflow name and the branch name for
  # pull requests or the commit hash for any other events.
  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
  cancel-in-progress: true

jobs:
  build:
    name: publish changelog
    runs-on: self-hosted
    environment: development
    permissions:
      pull-requests: write
      contents: write
    steps:
      - uses: actions/checkout@v2
      - uses: pnpm/action-setup@v2
        with:
          version: 'latest'

      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 18.x
          registry-url: https://npm.pkg.github.com
          scope: '@toeverything'
          cache: 'pnpm'

      - name: Install dependencies
        run: pnpm install --no-frozen-lockfile
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}

      - name: Create changelog
        id: changesets
        uses: changesets/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
