Skip to content

Commit 6b13706

Browse files
committed
ci: add manual deployment action
1 parent cbb62c9 commit 6b13706

File tree

3 files changed

+144
-50
lines changed

3 files changed

+144
-50
lines changed

.github/workflows/README.md

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,32 @@ This document describes the CI/CD architecture for the Apache Teaclave website.
66

77
```
88
.github/workflows/
9-
├── _reusable-build.yml # [Reusable] Shared build logic for Docker + website
10-
├── pr-validation.yml # PR validation workflow (read-only)
11-
├── deploy-staging.yml # Deployment workflow for staging
12-
└── README.md # This file
9+
├── _reusable-build.yml # [Reusable] Shared build logic for Docker + website
10+
├── pr-validation.yml # PR validation workflow (read-only)
11+
├── deploy-staging.yml # Deploys build to asf-staging branch
12+
├── promote-staging-to-production.yml # [Manual] Replaces asf-site with asf-staging
13+
└── README.md # This file
1314
```
1415

1516
### Naming Convention
1617

1718
- **`pr-*.yml`** - PR validation workflows (read-only permissions)
1819
- **`deploy-*.yml`** - Deployment workflows (write permissions)
20+
- **`promote-*.yml`** - Manual promotion workflows (e.g. staging → production)
1921
- **`_reusable-*.yml`** - Reusable workflows (called by others, underscore prefix)
2022

23+
## 🌐 Website Update Flow
24+
25+
1. **PR merged** (or push to `master`) → **Deploy Staging** runs → build is deployed to the **asf-staging** branch. Staging site is updated.
26+
2. **Verify** → Visit the staging website and confirm everything looks correct.
27+
3. **Promote to production** → Go to **Actions****"Promote Staging to Production"****Run workflow**. This replaces the **asf-site** branch with the content of **asf-staging**, updating the final live website.
28+
29+
| Step | What happens |
30+
|------|----------------|
31+
| Merge / push to master | `deploy-staging.yml``asf-staging` updated |
32+
| Manual check | You verify the staging site |
33+
| Manual trigger | `promote-staging-to-production.yml``asf-site` = `asf-staging` |
34+
2135
## 🏗️ Architecture Overview
2236

2337
### Design Principles
@@ -31,40 +45,37 @@ This document describes the CI/CD architecture for the Apache Teaclave website.
3145
### Architecture Diagram
3246

3347
```
34-
┌─────────────────────────────────────────────────────────────────┐
35-
│ GitHub Repository Events │
36-
│ │
37-
│ Pull Request Push to master Manual Trigger │
38-
│ │ │ │ │
39-
│ ▼ ▼ ▼ │
40-
│ ┌─────────────┐ ┌──────────────┐ ┌──────────────┐ │
41-
│ │pr-validation│ │deploy- │ │deploy- │ │
42-
│ │.yml │ │staging.yml │ │staging.yml │ │
43-
│ └────┬────────┘ └──────┬───────┘ └──────┬───────┘ │
44-
│ │ │ │ │
45-
│ │ ┌────────────┴──────────────────────┘ │
46-
│ │ │ │
47-
│ ▼ ▼ │
48-
│ ┌────────────────────────────────────────────────┐ │
49-
│ │ _reusable-build.yml (Shared Logic) │ │
50-
│ │ │ │
51-
│ │ ┌──────────────────┐ ┌────────────────────┐ │ │
52-
│ │ │ build-docker- │─▶│ build-website │ │ │
53-
│ │ │ image │ │ │ │ │
54-
│ │ └──────────────────┘ └────────────────────┘ │ │
55-
│ │ │ │
56-
│ │ Outputs: │ │
57-
│ │ - docker-artifact-name │ │
58-
│ │ - build-artifact-name │ │
59-
│ └─────────────────┬────────────────┬─────────────┘ │
60-
│ │ │ │
61-
│ ┌────────────┘ └────────────┐ │
62-
│ ▼ ▼ │
63-
│ ┌─────────┐ ┌──────────────┐ │
64-
│ │validate │ │deploy-staging│ │
65-
│ │ │ │ │ │
66-
│ └─────────┘ └──────────────┘ │
67-
│ │
68-
│ Result: ✓ PR Check Result: ✓ Deployed │
69-
└─────────────────────────────────────────────────────────────────┘
48+
┌─────────────────────────────────────────────────────────────────────────┐
49+
│ GitHub Repository Events │
50+
│ │
51+
│ Pull Request Push to master Manual Trigger │
52+
│ │ │ │ │
53+
│ ▼ ▼ ▼ │
54+
│ ┌─────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
55+
│ │pr-validation│ │deploy- │ │promote-staging-to- │ │
56+
│ │.yml │ │staging.yml │ │production.yml │ │
57+
│ └────┬────────┘ └──────┬───────┘ │ (manual only) │ │
58+
│ │ │ └──────────┬─────────────┘ │
59+
│ │ │ │ │
60+
│ ▼ ▼ │ │
61+
│ ┌────────────────────────────────────────┐ │ │
62+
│ │ _reusable-build.yml (Shared Logic) │ │ │
63+
│ │ build-docker-image → build-website │ │ │
64+
│ └────────────────────┬───────────────────┘ │ │
65+
│ │ │ │
66+
│ ┌────────────────┴────────────────┐ │ │
67+
│ ▼ ▼ ▼ │
68+
│ ┌─────────┐ ┌──────────────┐ ┌──────────────┐ │
69+
│ │ validate│ │deploy-staging│ │ promote │ │
70+
│ └─────────┘ └──────┬───────┘ │ (asf-staging│ │
71+
│ │ │ │ → asf-site)│ │
72+
│ │ ▼ └──────┬───────┘ │
73+
│ │ asf-staging │ │
74+
│ │ (staging site) ▼ │
75+
│ │ │ asf-site │
76+
│ │ │ (live site) │
77+
│ │ │ │
78+
│ ▼ └──► Verify staging, then run │
79+
│ Result: ✓ PR Check "Promote Staging to Production" │
80+
└─────────────────────────────────────────────────────────────────────────┘
7081
```
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Promote Staging to Production
2+
#
3+
# Manual-only workflow: after verifying the staging site, run this to replace
4+
# the production branch (asf-site) with the content of asf-staging.
5+
#
6+
# Flow:
7+
# 1. PR merged → deploy-staging.yml runs → asf-staging updated
8+
# 2. Visit staging website, verify it looks correct
9+
# 3. Go to Actions → "Promote Staging to Production" → Run workflow
10+
# 4. asf-site is replaced with asf-staging → final website updated
11+
12+
name: Promote Staging to Production
13+
14+
on:
15+
workflow_dispatch:
16+
17+
# Permissions to push to the production branch
18+
permissions:
19+
contents: write
20+
21+
# Prevent concurrent promotions
22+
concurrency:
23+
group: promote-staging-to-production
24+
cancel-in-progress: false
25+
26+
jobs:
27+
promote:
28+
name: Replace asf-site with asf-staging
29+
runs-on: ubuntu-22.04
30+
timeout-minutes: 10
31+
environment:
32+
name: production
33+
url: https://teaclave.apache.org
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4.2.2
38+
with:
39+
fetch-depth: 0
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
persist-credentials: false
42+
43+
- name: Fetch asf-staging
44+
run: |
45+
git fetch origin asf-staging
46+
if ! git rev-parse --verify origin/asf-staging >/dev/null 2>&1; then
47+
echo "Error: Branch asf-staging not found. Run deploy-staging first."
48+
exit 1
49+
fi
50+
echo "asf-staging is at: $(git rev-parse origin/asf-staging)"
51+
52+
- name: Replace asf-site with asf-staging
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
GITHUB_REPOSITORY: ${{ github.repository }}
56+
run: |
57+
set -euo pipefail
58+
59+
cleanup() {
60+
git config --local --unset-all http.https://github.com/.extraheader 2>/dev/null || true
61+
}
62+
trap cleanup EXIT INT TERM
63+
64+
git config user.name "github-actions[bot]"
65+
git config user.email "github-actions[bot]@users.noreply.github.com"
66+
git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n x-access-token:${GITHUB_TOKEN} | base64)"
67+
68+
# Push asf-staging to asf-site (replace production with staging content)
69+
git push https://github.com/${GITHUB_REPOSITORY}.git origin/asf-staging:asf-site --force
70+
71+
echo "✅ Production branch (asf-site) updated with content from asf-staging"
72+
73+
- name: Promotion Summary
74+
run: |
75+
echo "### ✅ Production Updated" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
echo "The **asf-site** branch has been replaced with the content of **asf-staging**." >> $GITHUB_STEP_SUMMARY
78+
echo "" >> $GITHUB_STEP_SUMMARY
79+
echo "#### Details" >> $GITHUB_STEP_SUMMARY
80+
echo "- **Source:** \`asf-staging\`" >> $GITHUB_STEP_SUMMARY
81+
echo "- **Target:** \`asf-site\` (production)" >> $GITHUB_STEP_SUMMARY
82+
echo "- **Triggered by:** @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
83+
echo "- **Timestamp:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
84+
echo "" >> $GITHUB_STEP_SUMMARY
85+
echo "The live website will reflect the new content shortly." >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@ The official website for Apache Teaclave™, generated with the Docusaurus stati
1818
make build
1919
```
2020

21-
### Deployment
21+
### Deployment (CI/CD)
2222

23-
To deploy the generated site to the staging and production environments:
23+
Deployment is handled by GitHub Actions:
2424

25-
```bash
26-
# Deploy to staging
27-
ghp-import --no-history --force site/build/ -b asf-staging
28-
git push -f asf-staging
25+
1. **Merge a PR** (or push to `master`) → the **Deploy Staging** workflow runs and updates the **asf-staging** branch.
26+
2. **Verify** the staging site.
27+
3. **Promote to production** → In the repo, go to **Actions****"Promote Staging to Production"****Run workflow**. This updates **asf-site** with the content of **asf-staging**.
2928

30-
# Deploy to production
31-
ghp-import --no-history --force site/build/ -b asf-site
32-
git push -f asf-site
33-
```
29+
For workflow details and architecture, see [.github/workflows/README.md](.github/workflows/README.md).
30+
31+
Manual deployment from a local build (e.g. `make staging` / `make site` in `site/`) is still supported; see `site/Makefile`.
3432

3533
### Website URLs
3634

0 commit comments

Comments
 (0)