mirror of
https://github.com/ziex-dev/ziex.git
synced 2026-07-21 02:59:36 -06:00
220 lines
5.3 KiB
YAML
220 lines
5.3 KiB
YAML
name: Docs
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'site/**'
|
|
- '.github/workflows/docs.yml'
|
|
- 'src/runtime/**'
|
|
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: 'pages'
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build_ssg:
|
|
runs-on: ubuntu-latest
|
|
name: Build (SSG)
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Zig
|
|
uses: mlugg/setup-zig@v2
|
|
with:
|
|
version: 0.16.0
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v1
|
|
with:
|
|
bun-version: 1.3.5
|
|
|
|
- name: Setup Pages
|
|
uses: actions/configure-pages@v5
|
|
|
|
- name: Install Node Dependencies
|
|
run: cd site && bun install
|
|
|
|
- name: Build Site
|
|
run: cd site && zig build -Doptimize=ReleaseSmall
|
|
|
|
- name: Export Site
|
|
run: cd site && zig build zx -- export
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: ./site/dist
|
|
|
|
pre_deploy:
|
|
name: Pre-deploy
|
|
uses: ./.github/workflows/e2e.yml
|
|
with:
|
|
report_name: playwright-report-pre-deploy
|
|
|
|
deploy_ssg:
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: [build_ssg, pre_deploy]
|
|
name: Deploy (SSG)
|
|
outputs:
|
|
page_url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|
|
|
|
post_deploy:
|
|
name: Post-deploy
|
|
needs: [deploy_ssg, deploy_edge, deploy_ssr]
|
|
uses: ./.github/workflows/e2e.yml
|
|
with:
|
|
base_url: ${{ needs.deploy_ssg.outputs.page_url }}
|
|
report_name: playwright-report-post-deploy
|
|
|
|
build_ssr:
|
|
if: false
|
|
runs-on: ubuntu-24.04-arm
|
|
name: Build (SSR)
|
|
env:
|
|
BUILD_ARCH: arm64
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./site/Dockerfile
|
|
tags: ziex:latest
|
|
outputs: type=docker,dest=/tmp/image-${{ env.BUILD_ARCH }}.tar
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Upload Docker image artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: docker-image-${{ env.BUILD_ARCH }}
|
|
path: /tmp/image-${{ env.BUILD_ARCH }}.tar
|
|
retention-days: 1
|
|
|
|
# Temp disable ssr build
|
|
deploy_ssr:
|
|
if: false
|
|
environment:
|
|
name: ssr
|
|
url: https://ssr.ziex.dev
|
|
runs-on: self-hosted
|
|
name: Deploy (SSR)
|
|
needs: [pre_deploy, build_ssr]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Detect architecture
|
|
id: arch
|
|
run: |
|
|
ARCH=$(uname -m)
|
|
if [[ "$ARCH" == "x86_64" ]]; then
|
|
echo "arch=amd64" >> $GITHUB_OUTPUT
|
|
elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then
|
|
echo "arch=arm64" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Unsupported architecture: $ARCH"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Download Docker image
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image-${{ steps.arch.outputs.arch }}
|
|
path: /tmp
|
|
|
|
- name: Load Docker image
|
|
run: docker load -i /tmp/image-${{ steps.arch.outputs.arch }}.tar
|
|
|
|
- name: Start containers
|
|
run: cd site && docker compose -f compose.yml up -d
|
|
|
|
- name: Connect to npm network
|
|
run: docker network connect npm ziex.dev || true
|
|
|
|
build_edge:
|
|
runs-on: ubuntu-latest
|
|
name: Build (Edge)
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Zig
|
|
uses: mlugg/setup-zig@v2
|
|
with:
|
|
version: 0.16.0
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v1
|
|
with:
|
|
bun-version: 1.3.5
|
|
|
|
- name: Install Node Dependencies
|
|
run: cd site && bun install
|
|
|
|
- name: Build Edge bundle artifact
|
|
run: cd site && npx wrangler deploy --dry-run --outdir .wrangler-artifact --assets ./zig-out/static
|
|
|
|
- name: Upload Edge build artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: edge-build-artifact
|
|
path: |
|
|
./site/.wrangler-artifact
|
|
./site/zig-out/static
|
|
include-hidden-files: true
|
|
retention-days: 1
|
|
|
|
deploy_edge:
|
|
environment:
|
|
name: edge
|
|
url: https://site.ziex.workers.dev
|
|
runs-on: ubuntu-latest
|
|
name: Deploy (Edge)
|
|
needs: [build_edge, pre_deploy]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v1
|
|
with:
|
|
bun-version: 1.3.5
|
|
|
|
- name: Download Edge build artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: edge-build-artifact
|
|
path: ./site
|
|
|
|
- name: Deploy to Edge
|
|
uses: cloudflare/wrangler-action@v3
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
wranglerVersion: 4
|
|
workingDirectory: ./site
|
|
command: deploy .wrangler-artifact/main.js --no-bundle --assets ./zig-out/static
|
|
|
|
|