Skip to content

Commit a656ee4

Browse files
authored
Add GitHub Actions workflow for deploying production Design System Docs (#103837)
* Move existing docs workflow to grouping folder * Add GitHub Actions workflow for deploying production Design System Docs * Flatten workflows to avoid recursive directory May not be supported after all * Move checkout back to individual actions Can't reference a composite action until the repo is checked out * Use scp instead of rsync rsync may not be available
1 parent 8fa7d91 commit a656ee4

3 files changed

Lines changed: 81 additions & 18 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build Design System Docs
2+
3+
description: Build the Design System Docs site
4+
5+
runs:
6+
using: composite
7+
steps:
8+
# 1. Set up Node
9+
- uses: actions/setup-node@v4
10+
with:
11+
node-version-file: .nvmrc
12+
cache: yarn
13+
14+
# 2. Install dependencies for just the design-system-docs package
15+
- run: yarn workspaces focus --production @automattic/design-system-docs
16+
shell: bash
17+
18+
# 3. Build the design-system-docs workspace
19+
- name: Build design system docs
20+
run: yarn workspace @automattic/design-system-docs build
21+
shell: bash
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy Design System Docs to Production
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
paths:
8+
- apps/design-system-docs/**
9+
- .github/actions/build-design-system-docs/action.yml
10+
- .github/workflows/ds-docs-deploy-production.yml
11+
12+
concurrency:
13+
group: deploy-production-design-system-docs
14+
cancel-in-progress: true
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
# 1. Checkout the PR code
22+
- uses: actions/checkout@v4
23+
24+
# 2. Build the Design System Docs site
25+
- uses: ./.github/actions/build-design-system-docs
26+
27+
# 3. Upload over SSH to the production server
28+
- name: Sync to production server
29+
env:
30+
# See: https://wp.me/p9o2xV-5Da#comment-11607
31+
SSH_USER: ${{ secrets.DESIGN_SYSTEM_PRODUCTION_SSH_USER }}
32+
SSH_PRIVATE_KEY: ${{ secrets.DESIGN_SYSTEM_PRODUCTION_SSH_KEY }}
33+
# Generated via: `ssh-keyscan -t ssh-ed25519 sftp.wp.com`. Stored as a secret not because
34+
# it's sensitive, but to make it easier to change without code revisions.
35+
SSH_HOST_PUBLIC_KEY: ${{ secrets.DESIGN_SYSTEM_PRODUCTION_SSH_PUBLIC_KEY }}
36+
run: |
37+
printf '%s' "$SSH_PRIVATE_KEY" > key.pem
38+
chmod 600 key.pem
39+
40+
# Write known_hosts with public key for strict key checking
41+
mkdir -p ~/.ssh
42+
echo "sftp.wp.com ssh-ed25519 $SSH_HOST_PUBLIC_KEY" > ~/.ssh/known_hosts
43+
44+
# Copy the built site to the production server
45+
scp -r -i key.pem \
46+
-o UserKnownHostsFile=~/.ssh/known_hosts \
47+
-o StrictHostKeyChecking=yes \
48+
apps/design-system-docs/dist/* \
49+
"$SSH_USER@sftp.wp.com:/srv/htdocs/"
50+
51+
rm key.pem
Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66
paths:
7-
- 'apps/design-system-docs/**'
8-
- .github/workflows/design-system-docs.yml
7+
- apps/design-system-docs/**
8+
- .github/actions/build-design-system-docs/action.yml
9+
- .github/workflows/ds-docs-pr-preview.yml
910

1011
# Ensure only one preview build runs per-PR at a time
1112
concurrency:
@@ -23,23 +24,13 @@ jobs:
2324
# 1. Checkout the PR code
2425
- uses: actions/checkout@v4
2526

26-
# 2. Set up Node
27-
- uses: actions/setup-node@v4
28-
with:
29-
node-version-file: .nvmrc
30-
cache: yarn
31-
32-
# 3. Install dependencies for just the design-system-docs package
33-
- run: yarn workspaces focus --production @automattic/design-system-docs
34-
35-
# 4. Build the design-system-docs workspace
36-
- name: Build design system docs
37-
run: yarn workspace @automattic/design-system-docs build
27+
# 2. Build the Design System Docs site
28+
- uses: ./.github/actions/build-design-system-docs
3829

39-
# 5. Install Wrangler
30+
# 3. Install Wrangler
4031
- run: npm install -g wrangler
4132

42-
# 6. Upload a new Worker version and capture the preview URL
33+
# 4. Upload a new Worker version and capture the preview URL
4334
- name: Upload Worker version
4435
id: upload
4536
env:
@@ -58,15 +49,15 @@ jobs:
5849
# Expose it to later steps
5950
echo "url=$URL" >> "$GITHUB_OUTPUT"
6051
61-
# 7. Try to find an existing comment with our marker
52+
# 5. Try to find an existing comment with our marker
6253
- name: Find preview comment
6354
id: find_comment
6455
uses: peter-evans/find-comment@v3
6556
with:
6657
issue-number: ${{ github.event.pull_request.number }}
6758
body-includes: '<!-- cf-preview-comment -->'
6859

69-
# 8. Create or update a comment that shows the preview URL
60+
# 6. Create or update a comment that shows the preview URL
7061
- name: Comment (create or update)
7162
uses: peter-evans/create-or-update-comment@v4
7263
with:

0 commit comments

Comments
 (0)