Skip to content

Commit dadcc0c

Browse files
committed
Feature: add staging deployment workflow, begin Astro setup
1 parent 64b8725 commit dadcc0c

9 files changed

Lines changed: 1381 additions & 1889 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: ['main', 'develop', 'staging']
6+
pull_request:
7+
branches: ['main']
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
pull-requests: write
15+
16+
concurrency:
17+
group: 'docs-${{ github.ref }}'
18+
cancel-in-progress: true
19+
20+
env:
21+
# Determine deployment environment based on branch
22+
DEPLOY_ENV: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
deploy-env: ${{ env.DEPLOY_ENV }}
29+
base-url: ${{ steps.base-url.outputs.url }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '22'
38+
cache: 'npm'
39+
40+
- name: Setup Pages (production only)
41+
if: github.ref_name == 'main'
42+
id: pages
43+
uses: actions/configure-pages@v4
44+
45+
- name: Determine base URL
46+
id: base-url
47+
run: |
48+
if [[ "${{ github.ref_name }}" == "main" ]]; then
49+
echo "url=" >> $GITHUB_OUTPUT
50+
else
51+
echo "url=/docs-${{ github.ref_name }}" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Build documentation
58+
run: npm run build
59+
env:
60+
# Set base URL for non-production builds
61+
BASE_URL: ${{ steps.base-url.outputs.url }}
62+
63+
- name: Upload artifact (production)
64+
if: github.ref_name == 'main'
65+
uses: actions/upload-pages-artifact@v3
66+
with:
67+
path: ./dist
68+
69+
- name: Upload artifact (staging)
70+
if: github.ref_name != 'main'
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: docs-${{ github.ref_name }}
74+
path: ./dist
75+
retention-days: 30
76+
77+
deploy-production:
78+
if: github.ref_name == 'main'
79+
environment:
80+
name: github-pages
81+
url: ${{ steps.deployment.outputs.page_url }}
82+
runs-on: ubuntu-latest
83+
needs: build
84+
steps:
85+
- name: Deploy to GitHub Pages
86+
id: deployment
87+
uses: actions/deploy-pages@v4
88+
89+
deploy-staging:
90+
if: github.ref_name != 'main' && github.event_name == 'push'
91+
runs-on: ubuntu-latest
92+
needs: build
93+
steps:
94+
- name: Checkout gh-pages
95+
uses: actions/checkout@v4
96+
with:
97+
ref: gh-pages
98+
token: ${{ secrets.GITHUB_TOKEN }}
99+
fetch-depth: 0
100+
101+
- name: Download staging artifact
102+
uses: actions/download-artifact@v4
103+
with:
104+
name: docs-${{ github.ref_name }}
105+
path: ./temp-staging
106+
107+
- name: Deploy to staging directory
108+
run: |
109+
# Create staging directory
110+
mkdir -p docs-${{ github.ref_name }}
111+
112+
# Copy built docs to staging directory
113+
cp -r temp-staging/* docs-${{ github.ref_name }}/
114+
115+
# Clean up temp directory
116+
rm -rf temp-staging
117+
118+
# Configure git
119+
git config user.name "github-actions[bot]"
120+
git config user.email "github-actions[bot]@users.noreply.github.com"
121+
122+
# Commit changes
123+
git add docs-${{ github.ref_name }}
124+
git commit -m "Deploy staging docs for ${{ github.ref_name }}" || exit 0
125+
git push
126+
127+
- name: Comment on PR with staging link
128+
if: github.event_name == 'pull_request'
129+
uses: actions/github-script@v7
130+
with:
131+
script: |
132+
const stagingUrl = `https://ahoy-cli.github.io/docs-${{ github.ref_name }}/`;
133+
const comment = `📖 **Documentation Preview**
134+
135+
Staging documentation is available at: ${stagingUrl}
136+
137+
This preview will be updated automatically with new commits to this branch.`;
138+
139+
github.rest.issues.createComment({
140+
issue_number: context.issue.number,
141+
owner: context.repo.owner,
142+
repo: context.repo.repo,
143+
body: comment
144+
});

original-info/README.md

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)