name: WebApp

on:
  release:
    types: [published]

env:
  BUILD_TYPE: MinSizeRel

jobs:
  webapp:
    runs-on: ubuntu-latest
    steps:
    - name: Setup Emscripten
      uses: mymindstorm/setup-emsdk@v7

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

    - name: Build
      run: |
        cd build
        emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
        cmake --build . --config $BUILD_TYPE --parallel
        cp bin/tic80.js webapp/tic80.js
        cp bin/tic80.wasm webapp/tic80.wasm

    - name: Deploy
      uses: JamesIves/github-pages-deploy-action@4.1.3
      with:
        branch: webapp
        folder: build/webapp
