Repository navigation
66 lines (54 loc) · 1.73 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
66 lines (54 loc) · 1.73 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
name: Deploy Docs
on:
workflow_dispatch:
jobs:
authorize:
name: Authorize User
runs-on: ubuntu-latest
steps:
- name: Check if user is authorized
run: |
AUTHORIZED_USERS="${{ secrets.DEPLOYMENT_AUTHORIZED_USERS }}"
CURRENT_USER="${{ github.actor }}"
if [ -z "$AUTHORIZED_USERS" ]; then
echo "❌ DEPLOYMENT_AUTHORIZED_USERS secret is not set"
exit 1
fi
# Convert comma-separated list to array and check if user is in list
IFS=',' read -ra USERS <<< "$AUTHORIZED_USERS"
AUTHORIZED=false
for user in "${USERS[@]}"; do
# Trim whitespace
user=$(echo "$user" | xargs)
if [ "$user" = "$CURRENT_USER" ]; then
AUTHORIZED=true
break
fi
done
if [ "$AUTHORIZED" = true ]; then
echo "✅ User '$CURRENT_USER' is authorized to run this workflow"
else
echo "❌ User '$CURRENT_USER' is not authorized to run this workflow"
echo "Authorized users: $AUTHORIZED_USERS"
exit 1
fi
deploy:
needs: authorize
name: Deploy Docs to Cloudflare
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build docs
run: npm run build -w @libretexts/davis-docs
- name: Deploy to Cloudflare
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: npm run deploy -w @libretexts/davis-docs