Skip to content

Commit

Permalink
build: deploy docs to GH Pages via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed May 19, 2024
1 parent c01cdb1 commit 2e14368
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
cache: 'pnpm'
- run: pnpm install
- name: Test with coverage
run: pnpm run test:unit:coverage
run: pnpm turbo test:unit:coverage
# steps:
# - name: Check out code
# uses: actions/checkout@v4
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy (Docs)

on:
push:
branches:
- main
paths:
- 'apps/docs/**'
- '!**/README.md'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

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

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛫
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages 📄
uses: actions/configure-pages@v5
- name: Setup PNPM 📃
uses: pnpm/action-setup@v3
- name: Setup Node 📐
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'pnpm'
# - name: Filter Docs 📃
# run: pnpm turbo prune --scope=docs
- name: Install dependencies 💎
run: pnpm install
- name: Build 🏗️
run: pnpm turbo build --filter=docs
- name: Upload Artifact ☁️
uses: actions/upload-pages-artifact@v3
with:
path: apps/docs/dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages 💖
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion apps/docs/.env.prod.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SITE_URL=https://spectacular-docs.vercel.app
GH_SITE_URL=https://xmlking.github.io/spectacular/
1 change: 1 addition & 0 deletions apps/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist/
build/

# generated types
.astro/
Expand Down
16 changes: 11 additions & 5 deletions apps/docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import node from '@astrojs/node';
// import vercel from "@astrojs/vercel/serverless";
import vercel from '@astrojs/vercel/static';

const SITE_URL =
process.env.VERCEL_ENV === 'production' ? process.env.SITE_URL : 'http://localhost:4321/';
/* https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables */
const VERCEL_SITE_URL =
process.env.VERCEL_ENV == 'production' &&
process.env.VERCEL_URL &&
`https://${process.env.VERCEL_URL}`;

const site = VERCEL_SITE_URL || process.env.GH_SITE_URL || 'http://localhost:4321/';
const base = process.env.GH_SITE_URL ? '/spectacular' : ''

// https://astro.build/config
export default defineConfig({
site: SITE_URL,
site,
integrations: [
starlight({
title: 'Docs',
Expand Down Expand Up @@ -40,14 +46,14 @@ export default defineConfig({
tag: 'meta',
attrs: {
property: 'og:image',
content: SITE_URL + 'og.jpg?v=1'
content: site + 'og.jpg?v=1'
}
},
{
tag: 'meta',
attrs: {
property: 'twitter:image',
content: SITE_URL + 'og.jpg?v=1'
content: site + 'og.jpg?v=1'
}
}
],
Expand Down

0 comments on commit 2e14368

Please sign in to comment.