Migrate to @pocka/rollup-plugin-gleam #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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-castle-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/castle" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: castle-storybook | |
path: storybook-static/castle | |
build-simple-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/simple" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: simple-storybook | |
path: storybook-static/simple | |
build-builder-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/builder" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: builder-storybook | |
path: storybook-static/builder | |
prep-artifact-for-pages: | |
# Deploy only on master branch | |
if: github.ref == 'refs/heads/master' | |
needs: | |
- build | |
- build-castle-storybook | |
- build-simple-storybook | |
- build-builder-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-castle-storybook | |
- test-simple-storybook | |
- test-builder-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-castle-storybook: | |
needs: | |
- build-castle-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: "castle-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" \ | |
"npx http-server storybook-static --port 6006 --silent" \ | |
"npx wait-on tcp:6006 && bun run test:storybook/castle --browsers chromium,firefox,webkit" | |
test-simple-storybook: | |
needs: | |
- build-simple-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: "simple-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" \ | |
"npx http-server storybook-static --port 6006 --silent" \ | |
"npx wait-on tcp:6006 && bun run test:storybook/simple --browsers chromium,firefox,webkit" | |
test-builder-storybook: | |
needs: | |
- build-builder-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: "builder-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" \ | |
"npx http-server storybook-static --port 6007 --silent" \ | |
"npx wait-on tcp:6007 && bun run test:storybook/builder --browsers chromium,firefox,webkit" | |
cleanup: | |
needs: | |
- deploy | |
- test-builder-storybook | |
- test-castle-storybook | |
- test-simple-storybook | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete artifacts | |
uses: geekyeggo/delete-artifact@v5 | |
with: | |
name: "*" |