-
-
Notifications
You must be signed in to change notification settings - Fork 14
125 lines (102 loc) · 2.82 KB
/
a-b-deploy.yml
File metadata and controls
125 lines (102 loc) · 2.82 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: Build & Deploy Docusaurus Site
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
target:
description: "Deploy target"
required: true
default: "gh"
type: choice
options:
- gh
- dreamhost
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
name: Build site
runs-on: ubuntu-latest
outputs:
deploy_target: ${{ steps.set-target.outputs.target }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set deploy target
id: set-target
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "target=${{ inputs.target }}" >> $GITHUB_OUTPUT
else
echo "target=gh" >> $GITHUB_OUTPUT
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: website/package-lock.json
- name: Install dependencies
run: |
cd website
npm ci
- name: Build Docusaurus site
env:
DEPLOY_TARGET: ${{ steps.set-target.outputs.target }}
run: |
cd website
npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: docusaurus-build
path: website/build
deploy-gh-pages:
name: Deploy to GitHub Pages
needs: build
if: |
needs.build.outputs.deploy_target == 'gh' &&
github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment:
name: github-pages
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: docusaurus-build
path: build
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: build
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
deploy-dreamhost:
name: Deploy to DreamHost
needs: build
if: |
needs.build.outputs.deploy_target == 'dreamhost' &&
github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: docusaurus-build
path: build
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DREAMHOST_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.DREAMHOST_HOST }} >> ~/.ssh/known_hosts
- name: Deploy via rsync
run: |
rsync -avz --delete build/ \
${{ secrets.DREAMHOST_USER }}@${{ secrets.DREAMHOST_HOST }}:${{ secrets.DREAMHOST_PATH }}/