-
-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (105 loc) · 4.53 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
125 lines (105 loc) · 4.53 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Deploy Documentation
on:
push:
branches:
- main
paths:
- 'README.md' # Monorepo root
- 'CONTRIBUTING.md' # Monorepo root
- 'LICENSE' # Monorepo root
- 'extensions/git-id-switcher/README.md' # Extension root (English)
- 'extensions/git-id-switcher/LICENSE' # Extension root
- 'extensions/git-id-switcher/CHANGELOG.md' # Extension root
- 'extensions/git-id-switcher/docs/**' # All language READMEs + docs
workflow_dispatch: # Manual trigger
permissions: read-all
jobs:
deploy:
runs-on: ubuntu-latest
# Prevent forks from deploying (no Cloudflare secrets)
if: github.repository == 'nullvariant/nullvariant-vscode-extensions'
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Node.js
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: '20'
- name: Install wrangler
run: npm install -g wrangler@4.54.0
- name: Deploy documentation to R2
run: |
R2_BASE="nullvariant-assets/nullvariant-vscode-extensions"
EXT_PATH="extensions/git-id-switcher"
# === Monorepo root files ===
echo "=== Deploying monorepo root files ==="
if [ -f "README.md" ]; then
echo "Deploying monorepo README.md..."
wrangler r2 object put "${R2_BASE}/README.md" \
--file "README.md" \
--content-type "text/markdown; charset=utf-8" \
--remote
fi
if [ -f "CONTRIBUTING.md" ]; then
echo "Deploying monorepo CONTRIBUTING.md..."
wrangler r2 object put "${R2_BASE}/CONTRIBUTING.md" \
--file "CONTRIBUTING.md" \
--content-type "text/markdown; charset=utf-8" \
--remote
fi
if [ -f "LICENSE" ]; then
echo "Deploying monorepo LICENSE..."
wrangler r2 object put "${R2_BASE}/LICENSE" \
--file "LICENSE" \
--content-type "text/plain; charset=utf-8" \
--remote
fi
# === Extension root files ===
echo "=== Deploying extension root files ==="
# English README (extension root)
echo "Deploying extension README.md (English)..."
wrangler r2 object put "${R2_BASE}/${EXT_PATH}/README.md" \
--file "${EXT_PATH}/README.md" \
--content-type "text/markdown; charset=utf-8" \
--remote
if [ -f "${EXT_PATH}/LICENSE" ]; then
echo "Deploying extension LICENSE..."
wrangler r2 object put "${R2_BASE}/${EXT_PATH}/LICENSE" \
--file "${EXT_PATH}/LICENSE" \
--content-type "text/plain; charset=utf-8" \
--remote
fi
if [ -f "${EXT_PATH}/CHANGELOG.md" ]; then
echo "Deploying extension CHANGELOG.md..."
wrangler r2 object put "${R2_BASE}/${EXT_PATH}/CHANGELOG.md" \
--file "${EXT_PATH}/CHANGELOG.md" \
--content-type "text/markdown; charset=utf-8" \
--remote
fi
# === Extension docs files ===
echo "=== Deploying extension docs files ==="
# Deploy all .md files in docs/ (CONTRIBUTING.md, LANGUAGES.md, etc.)
for doc_file in ${EXT_PATH}/docs/*.md; do
if [ -f "$doc_file" ]; then
filename=$(basename "$doc_file")
echo "Deploying docs/${filename}..."
wrangler r2 object put "${R2_BASE}/${EXT_PATH}/docs/${filename}" \
--file "$doc_file" \
--content-type "text/markdown; charset=utf-8" \
--remote
fi
done
# === Language-specific READMEs ===
echo "=== Deploying language-specific READMEs ==="
for lang_dir in ${EXT_PATH}/docs/i18n/*/; do
lang=$(basename "$lang_dir")
echo "Deploying ${lang}/README.md..."
wrangler r2 object put "${R2_BASE}/${EXT_PATH}/docs/i18n/${lang}/README.md" \
--file "${lang_dir}README.md" \
--content-type "text/markdown; charset=utf-8" \
--remote
done
echo "=== Documentation deployed successfully! ==="
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}