Skip to content

Commit 26df6a2

Browse files
committed
feat(ci): add PR preview deployments
- Add pr-preview.yml workflow using rossjrw/pr-preview-action - Update astro.config.mjs to support dynamic base path via ASTRO_BASE env - Previews deploy to /pr-preview/pr-<number>/ on gh-pages branch - Auto-cleanup when PR is closed
1 parent 611474f commit 26df6a2

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

.github/workflows/pr-preview.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# PR Preview deployment workflow
2+
# Deploys a preview of pull requests to GitHub Pages subdirectory
3+
4+
name: Deploy PR Preview
5+
6+
on:
7+
pull_request:
8+
types: [opened, reopened, synchronize, closed]
9+
paths:
10+
- 'website/**'
11+
- 'agents/**'
12+
- 'prompts/**'
13+
- 'instructions/**'
14+
- 'skills/**'
15+
- 'collections/**'
16+
- 'cookbook/**'
17+
- 'eng/generate-website-data.mjs'
18+
19+
concurrency:
20+
group: pr-preview-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
27+
jobs:
28+
deploy-preview:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
if: github.event.action != 'closed'
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
cache: 'npm'
40+
41+
- name: Install root dependencies
42+
if: github.event.action != 'closed'
43+
run: npm ci
44+
45+
- name: Install website dependencies
46+
if: github.event.action != 'closed'
47+
run: npm ci
48+
working-directory: ./website
49+
50+
- name: Generate website data
51+
if: github.event.action != 'closed'
52+
run: npm run website:data
53+
54+
- name: Build Astro site
55+
if: github.event.action != 'closed'
56+
run: npm run build
57+
working-directory: ./website
58+
env:
59+
# Set base path for PR preview subdirectory
60+
ASTRO_BASE: /awesome-copilot/pr-preview/pr-${{ github.event.number }}
61+
62+
- name: Deploy PR preview
63+
uses: rossjrw/pr-preview-action@v1
64+
with:
65+
source-dir: ./website/dist/
66+
preview-branch: gh-pages
67+
umbrella-dir: pr-preview
68+
action: auto

website/astro.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import sitemap from "@astrojs/sitemap";
22
import { defineConfig } from "astro/config";
33

4+
// Support dynamic base path for PR previews via ASTRO_BASE env var
5+
const base = process.env.ASTRO_BASE || "/";
6+
47
// https://astro.build/config
58
export default defineConfig({
69
site: "https://github.github.io",
7-
base: "/",
10+
base: base,
811
output: "static",
912
integrations: [sitemap()],
1013
build: {

0 commit comments

Comments
 (0)