Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Deploy Site to GitHub Pages

on:
workflow_dispatch:
push:
branches:
- main
paths:
- "site/**"
- ".github/workflows/deploy.yml"

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Build Site
runs-on: ubuntu-latest
defaults:
run:
working-directory: site
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: site/package-lock.json

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Install dependencies
run: npm ci --include=optional

- name: Work around npm optional dependency bug (Rollup native)
run: |
ROLLUP_NATIVE_PKG='@rollup/rollup-linux-x64-gnu'
if [ "$(uname -m)" = "aarch64" ]; then
ROLLUP_NATIVE_PKG='@rollup/rollup-linux-arm64-gnu'
fi
npm install --no-save "$ROLLUP_NATIVE_PKG"

- name: Build site
run: npm run build
env:
PUBLIC_SITE_BASE: ${{ steps.pages.outputs.base_path }}

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site/dist

deploy:
name: Deploy to Pages
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ cd site
npm run build
```

For project pages (`https://<user>.github.io/<repo>/`), set `PUBLIC_SITE_BASE`:

```bash
cd site
PUBLIC_SITE_BASE=/nue-lang.com/ npm run build
```

Theme can be selected at build time via `PUBLIC_THEME`:

```bash
Expand All @@ -33,6 +40,16 @@ PUBLIC_THEME=signal npm run build

If `PUBLIC_THEME` is omitted, `signal` is used.

## GitHub Pages Deploy

The workflow `.github/workflows/deploy.yml` deploys `site/dist` to GitHub Pages on push to `main`.

Setup once in repository settings:

- `Settings > Pages > Source` to `GitHub Actions`

`PUBLIC_SITE_BASE` is wired automatically by `actions/configure-pages` in CI.

## Home Playground Embed

Home embeds the WASM playground as an Astro React island.
Expand Down
10 changes: 9 additions & 1 deletion site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ npm run dev
npm run build
```

For project pages (`https://<user>.github.io/<repo>/`), set `PUBLIC_SITE_BASE`:

```bash
PUBLIC_SITE_BASE=/nue-lang.com/ npm run build
```

### Build with theme

Set `PUBLIC_THEME` at build time.
Expand All @@ -28,7 +34,9 @@ PUBLIC_THEME=signal npm run build

If omitted, `signal` is used.

When deploying (for example to GitHub Pages), publish this `site/` directory only.
When deploying with GitHub Pages via this repository, use `.github/workflows/deploy.yml`.
The workflow publishes `site/dist` and sets `PUBLIC_SITE_BASE` automatically with
`actions/configure-pages`.

## Home Playground Embed

Expand Down
2 changes: 2 additions & 0 deletions site/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import mdx from "@astrojs/mdx";
import react from "@astrojs/react";

export default defineConfig({
output: "static",
base: process.env.PUBLIC_SITE_BASE || "/",
integrations: [mdx(), react()]
});