name: Release CI
on:
  push:
    branches:
    - master

jobs:
  release:
    name: Release
    runs-on: ubuntu-20.04

    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: Setup Node.js
      uses: actions/setup-node@v1
      with:
        node-version: 16

    - name: Install dependencies
      run: npm ci

    - name: Create Build
      run: npm run build

    - name: Release Package
      env:
        GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
        NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
      run: npx semantic-release

    - name: Deploy to GH pages
      env:
        GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
        NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
      run: npx deploy-storybook-ci
