Skip to content

Commit 3e3f34d

Browse files
committed
feat(ci): unified registry deploy workflow and docs deploy pipeline
- Replace separate registry-api.yml and registry-web.yml with unified registry-deploy.yml (test -> build -> push -> deploy with OIDC + Instance Connect) - Add docs-deploy.yml for building Docusaurus and rsyncing to EC2 - Simplify docs.yml to versioning-only (strip GH Pages deploy)
1 parent 5851715 commit 3e3f34d

2 files changed

Lines changed: 81 additions & 47 deletions

File tree

.github/workflows/docs-deploy.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Deploy docs to EC2 (hivemind.rithul.dev)
2+
# Builds Docusaurus from website/, rsyncs to EC2, reloads Caddy.
3+
#
4+
# Prerequisite on EC2:
5+
# sudo mkdir -p /opt/hivemind-docs && sudo chown ubuntu:ubuntu /opt/hivemind-docs
6+
# Caddy must have a server block for hivemind.rithul.dev (see deploy/Caddyfile).
7+
8+
name: Docs Deploy
9+
10+
on:
11+
push:
12+
branches: [main]
13+
paths:
14+
- "website/**"
15+
- ".github/workflows/docs-deploy.yml"
16+
workflow_dispatch:
17+
18+
concurrency:
19+
group: docs-deploy
20+
cancel-in-progress: true
21+
22+
jobs:
23+
deploy:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
id-token: write
28+
env:
29+
EC2_HOST: ${{ vars.REGISTRY_EC2_HOST }}
30+
EC2_INSTANCE_ID: ${{ vars.REGISTRY_EC2_INSTANCE_ID }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Set up Node
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "20"
38+
cache: "npm"
39+
cache-dependency-path: website/package-lock.json
40+
41+
- name: Install and build
42+
run: |
43+
cd website
44+
npm ci
45+
npm run build
46+
47+
- uses: aws-actions/configure-aws-credentials@v4
48+
with:
49+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/hivemind-registry-deploy
50+
aws-region: us-east-1
51+
52+
- name: Deploy to EC2 via Instance Connect
53+
run: |
54+
# Generate ephemeral SSH key
55+
ssh-keygen -t ed25519 -f /tmp/deploy_key -N "" -q
56+
aws ec2-instance-connect send-ssh-public-key \
57+
--instance-id "$EC2_INSTANCE_ID" \
58+
--instance-os-user ubuntu \
59+
--ssh-public-key file:///tmp/deploy_key.pub
60+
61+
# Rsync build output to EC2
62+
rsync -azP --delete \
63+
-e "ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no" \
64+
website/build/ \
65+
ubuntu@"$EC2_HOST":/opt/hivemind-docs/
66+
67+
rm -f /tmp/deploy_key /tmp/deploy_key.pub
68+
69+
- name: Verify deployment
70+
run: |
71+
sleep 3
72+
curl -sf --retry 3 --retry-delay 5 "https://hivemind.rithul.dev/" || \
73+
{ echo "FAIL: docs site not responding"; exit 1; }
74+
echo "Docs deployment verified"

.github/workflows/docs.yml

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
1-
# Deploy docs to GitHub Pages (hivemind.rithul.dev)
2-
# - On push to main: build Docusaurus and deploy to gh-pages
3-
# - On release published: open a PR with versioned docs (merge it to update main; workflow never pushes to main = no diverging branch).
1+
# Docs versioning: on release, create a versioned docs snapshot and open a PR.
2+
# Actual deployment is handled by docs-deploy.yml (pushes to EC2).
43
#
5-
# Required: Repo Settings → Pages → Build and deployment → Source:
6-
# "Deploy from a branch" → Branch: gh-pages → / (root)
4+
# On release published: creates versioned docs via docusaurus docs:version,
5+
# then opens a PR to merge the versioned snapshot into main.
76

8-
name: Docs
7+
name: Docs Version
98

109
on:
11-
push:
12-
branches: [main]
13-
paths:
14-
- ".github/workflows/docs.yml"
15-
- "website/**"
1610
release:
1711
types: [published]
1812

1913
permissions:
2014
contents: write
21-
pages: write
22-
id-token: write
15+
pull-requests: write
2316

2417
concurrency:
25-
group: docs
18+
group: docs-version
2619
cancel-in-progress: false
2720

2821
jobs:
2922
add-version:
30-
if: github.event_name == 'release'
3123
runs-on: ubuntu-latest
32-
permissions:
33-
contents: write
34-
pull-requests: write
3524
steps:
3625
- name: Checkout main
3726
uses: actions/checkout@v4
@@ -74,32 +63,3 @@ jobs:
7463
website/versioned_sidebars
7564
website/versions.json
7665
delete-branch: true
77-
78-
deploy:
79-
if: github.event_name == 'push'
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Checkout
83-
uses: actions/checkout@v4
84-
with:
85-
fetch-depth: 0
86-
87-
- name: Set up Node
88-
uses: actions/setup-node@v4
89-
with:
90-
node-version: "20"
91-
cache: "npm"
92-
cache-dependency-path: website/package-lock.json
93-
94-
- name: Install and build
95-
run: |
96-
cd website
97-
npm ci
98-
npm run build
99-
100-
- name: Deploy to GitHub Pages
101-
uses: peaceiris/actions-gh-pages@v3
102-
with:
103-
github_token: ${{ secrets.GITHUB_TOKEN }}
104-
publish_dir: website/build
105-
cname: hivemind.rithul.dev

0 commit comments

Comments
 (0)