From 73f1a2fcc78cd0be406f9ee2214b4ade4aa049a6 Mon Sep 17 00:00:00 2001 From: Matthew Scharley Date: Fri, 14 Jun 2024 11:49:10 +1000 Subject: [PATCH] ci: attempt to deploy the demo to github pages --- .github/workflows/demo.yml | 54 ++++++++++++++++++++++++++ bin/build-demo.sh | 18 +++++++++ demo/.gitignore | 1 + demo/src/commonmark_demo/message.gleam | 1 - 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/demo.yml create mode 100755 bin/build-demo.sh diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml new file mode 100644 index 0000000..4e021c5 --- /dev/null +++ b/.github/workflows/demo.yml @@ -0,0 +1,54 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.tool-versions' + - uses: erlef/setup-beam@v1 + with: + version-file: '.tool-versions' + version-type: 'strict' + - name: Build demo + run: ./bin/build-demo.sh + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: './demo/out' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + diff --git a/bin/build-demo.sh b/bin/build-demo.sh new file mode 100755 index 0000000..b79b9b2 --- /dev/null +++ b/bin/build-demo.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +# Move to the correct folder +cd demo/ +set -x + +# Do a build +gleam build + +# Move all the static files into place +for f in index.html build/dev/javascript/lustre_ui/priv/static/lustre-ui.css; do + mkdir -p ./out/$(dirname $f) + cp ./$f ./out/$f +done + +# Bundle all our JavaScript together +mkdir -p ./priv/static +./build/.lustre/bin/esbuild ./priv/static/commonmark_demo.mjs --bundle --outfile=./out/priv/static/commonmark_demo.mjs diff --git a/demo/.gitignore b/demo/.gitignore index 95cccf2..23b8eed 100644 --- a/demo/.gitignore +++ b/demo/.gitignore @@ -3,3 +3,4 @@ /build /priv erl_crash.dump +/out diff --git a/demo/src/commonmark_demo/message.gleam b/demo/src/commonmark_demo/message.gleam index d5f4851..f2b42b8 100644 --- a/demo/src/commonmark_demo/message.gleam +++ b/demo/src/commonmark_demo/message.gleam @@ -1,6 +1,5 @@ import commonmark import commonmark_demo/model.{type Model, Model} -import gleam/io import lustre/effect pub type Msg {