---
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#######################################
# Start the job on all push to master #
#######################################
name: 'Build & Deploy - ALPHA'
on:
  push:
    branches:
      - alpha
      - dev

###############
# Set the Job #
###############
jobs:
  deploy:
    name: Build & Deploy alpha
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      # Setup .npmrc file to publish to npm
      - uses: actions/setup-node@v1
        with:
          node-version: '14.x'
          registry-url: 'https://registry.npmjs.org'
          always-auth: true
          # Defaults to the user or organization that owns the workflow file
          scope: 'nvuillam'
      - run: yarn
      - run: yarn config set version-git-tag false
      - run: ALPHAID=$(date '+%Y%m%d%H%M') && yarn version --prepatch --preid="alpha$ALPHAID"
      - run: yarn publish --tag alpha
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
