# Deploy on push to master
#
# This workflow is custom for layout's stories as this UI does not have a dedicated package.json.
#
#	1. build the project
#	2. deploy the project

# It relies on the `FIREBASE_TOKEN` secret being available in this repo.

name: deploy-layout-stories

on:
  push:
    branches:
    - master
    paths:
    - 'layout/**'

jobs:
  build-and-deploy:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x]

    steps:
    - uses: actions/checkout@v2

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

    - name: Build project
      run: |
        npm ci
        npx boostrap
        npx lerna run --scope layout build-storybook

    - name: Deploy to Firebase
      uses: w9jds/firebase-action@master
      with:
        args: deploy --only hosting
      env:
        FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
        PROJECT_PATH: 'layout'