Repository navigation
84 lines (73 loc) · 2.5 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
84 lines (73 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Deploy Website + Docs to GitHub Pages
on:
push:
branches:
- main
paths:
- 'apps/website/**'
- 'docs/**'
- '.github/workflows/deploy-docs.yml'
workflow_dispatch:
repository_dispatch:
types: [pages-health-failure]
permissions:
contents: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Build Website (Vite React SPA)
- name: Install apps/website dependencies
run: cd apps/website && npm install
- name: Build apps/website
run: cd apps/website && npm run build:ci
# Build Docsite (Docusaurus)
- name: Install docs dependencies
working-directory: docs
run: npm install
- name: Build docs
working-directory: docs
run: npm run build
# Combine builds
- name: Combine apps/website + docs
run: |
mkdir -p combined
cp -r apps/website/dist/* combined/
# Copy CNAME from public (if exists)
cp apps/website/public/CNAME combined/ 2>/dev/null || true
mkdir -p combined/docs
cp -r docs/build/* combined/docs/
touch combined/.nojekyll
# Deploy to gh-pages branch directly
- name: Deploy to gh-pages
env:
# Never interpolate a commit message straight into the shell: arbitrary
# text (parentheses, quotes, newlines) breaks the script — and worse,
# it is a command-injection vector. Pass it as an environment variable.
HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
cd combined
git init -q
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
# Subject line stays deterministic; the source message goes in the body,
# quoted so it cannot be interpreted as shell.
git commit -q \
-m "Deploy ${GITHUB_SHA}" \
-m "${HEAD_COMMIT_MESSAGE:-manual dispatch}" \
|| { echo "Nothing to deploy"; exit 0; }
git push --force "https://x-access-token:${GH_TOKEN}@github.com/gHashTag/trinity.git" HEAD:gh-pages