name: CI Canary

on: [pull_request]

jobs:
  build_test_lint:
    name: Node Smoke Test Befor Canary
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
          registry-url: 'https://registry.verdaccio.org'
      - name: Install
        run: yarn install --frozen-lockfile
      - name: Lint
        run: yarn lint
      - name: Build
        run: yarn build
      - name: Archive production artifacts
        uses: actions/upload-artifact@v1
        with:
          name: static
          path: static
  canary:
    name: Publish Canary Version of a PR
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Download math result for job 2
        uses: actions/download-artifact@v1
        with:
          name: static
      - uses: verdaccio/github-actions/canary@v0.4.0
        with:
          message: 'Thanks for your PR, the @verdaccio/ui package will be accessible from here for testing purposes:'
          is-global: false
          package-name: '@verdaccio/ui-theme'
          registry: 'https://registry.verdaccio.org'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          bot-token: ${{ secrets.VERDACCIO_BOT_TOKEN }}
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
          registry-url: 'https://registry.verdaccio.org'
      - run: npm publish --tag canary
        env:
          NODE_AUTH_TOKEN: ${{ secrets.VERDACCIO_TOKEN }}
    needs: build_test_lint
