Skip to content

Merge web_player and web_builder into one #1

Merge web_player and web_builder into one

Merge web_player and web_builder into one #1

Workflow file for this run

# SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com>
#
# SPDX-License-Identifier: Apache-2.0
name: Build and deploy web application
on:
push:
# Runs on every push
branches:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Gleam
uses: erlef/setup-beam@v1
with:
otp-version: "27"
gleam-version: "1.4"
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1"
- name: Install dependencies
run: "bun i"
- name: Build the app
run: "bun run build --base '/${{ github.event.repository.name }}/'"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: main
path: dist
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Gleam
uses: erlef/setup-beam@v1
with:
otp-version: "27"
gleam-version: "1.4"
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1"
- name: Install dependencies
run: "bun i"
- name: Check TypeScript types
run: "bunx tsc"
- name: Check Gleam types
run: "gleam check"
build-storybook:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Gleam
uses: erlef/setup-beam@v1
with:
otp-version: "27"
gleam-version: "1.4"
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1"
- name: Install dependencies
run: "bun i"
- name: Build Storybook
run: "bun run build:storybook"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: storybook
path: storybook-static
prep-artifact-for-pages:
# Deploy only on master branch
if: github.ref == 'refs/heads/master'
needs:
- build
- build-storybook
runs-on: ubuntu-latest
steps:
- name: Download main artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
name: main
- name: Download sub artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: "!main"
- name: Upload artifact for Pages
uses: actions/upload-pages-artifact@v3
with:
path: artifacts
deploy:
# Deploy only on master branch
if: github.ref == 'refs/heads/master'
concurrency:
group: deploy-ghpages
needs:
- check
- prep-artifact-for-pages
- test-storybook
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
test-storybook:
needs:
- build-storybook
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built Storybook
uses: actions/download-artifact@v4
with:
path: storybook-static
name: storybook
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1"
# Needs Node.js since bunx is not compatible with npx
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: Install dependencies
run: "bun i"
- name: Setup Playwright
run: "npx playwright install --with-deps"
- name: Run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on tcp:6006 && bun run test:storybook --browsers chromium,firefox,webkit"
cleanup:
needs:
- deploy
- test-storybook
runs-on: ubuntu-latest
steps:
- name: Delete artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: "*"