name: CD

on: create
env: 
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:

  deploy:
    if: (github.event.ref_type == 'tag')
    runs-on: ubuntu-latest
    steps:

      - name: Checkout source code
        uses: actions/checkout@v3

        # Make sure the version number in the tag matches the version in package.json
      - name: match-tag-to-package-version
        uses: geritol/match-tag-to-package-version@0.2.0 # https://github.com/geritol/match-tag-to-package-version
        env:
          TAG_PREFIX: refs/tags/

        # Install deps, build, pack and deploy
      - name: Build
        run: yarn install && yarn vsce publish
        env:
          VSCE_PAT: ${{secrets.VSCE_PAT}}
