name: Publish

on:
  workflow_run:

    workflows:
      - "Pre Publish Code"
    types:
      - completed


jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@v2
        with:
          node-version: '16'
      - run: npm install
      - run: npm run build
      - name: Semantic Release
        uses: cycjimmy/semantic-release-action@v2
        env:
          # secrets.GITHUB_TOKEN does not have necessary permissions
          GH_TOKEN: ${{ secrets.SEMENTIC_AND_DEPBOT_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
