-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (191 loc) · 6.88 KB
/
Copy pathdeploy-wpe-dev.yml
File metadata and controls
227 lines (191 loc) · 6.88 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Deploy to Dev
on:
workflow_dispatch:
inputs:
deploy_muplugins:
type: boolean
description: MU-Plugins
default: true
deploy_plugins:
type: boolean
description: Plugins
deploy_root:
type: boolean
description: Root files
deploy_themes:
type: boolean
description: Themes
default: true
env:
INSTALL:
SSH_HOST:
jobs:
backup-root-placeholder:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_root }}
steps:
- run: echo "Placeholder for unnecessary backup job"
backup-plugins:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_plugins }}
steps:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Backup plugins
run: ssh -i ~/.ssh/deploy-wpengine $INSTALL@$SSH_HOST 'zip -r --filesync --test --display-bytes --display-counts sites/${{ env.INSTALL }}/_wpeprivate/backup-plugins.zip sites/${{ env.INSTALL }}/wp-content/plugins'
backup-muplugins:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_muplugins }}
steps:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Backup mu-plugins
run: ssh -i ~/.ssh/deploy-wpengine $INSTALL@$SSH_HOST 'zip -r --filesync --test --display-bytes --display-counts sites/${{ env.INSTALL }}/_wpeprivate/backup-muplugins.zip sites/${{ env.INSTALL }}/wp-content/mu-plugins'
backup-themes:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_themes }}
steps:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Backup themes
run: ssh -i ~/.ssh/deploy-wpengine $INSTALL@$SSH_HOST 'zip -r --filesync --test --display-bytes --display-counts sites/${{ env.INSTALL }}/_wpeprivate/backup-themes.zip sites/${{ env.INSTALL }}/wp-content/themes'
deploy-root:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_root }}
needs: [ backup-root-placeholder ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy root
run: |
rsync -chavP --stats \
-e 'ssh -i ~/.ssh/deploy-wpengine' \
--exclude /.git/ \
--exclude /.github/ \
--exclude /.gitignore \
--exclude /.ssh/ \
--exclude /.editorconfig \
--exclude /wp-config-sample.php \
--exclude /wp-content/ \
--filter=':- /.gitignore' \
./ "$INSTALL@$SSH_HOST:/sites/$INSTALL/"
deploy-plugins:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_plugins }}
needs: [ backup-plugins ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy plugins
run: |
rsync -chavP --delete --stats \
-e 'ssh -i ~/.ssh/deploy-wpengine' \
--exclude /.git/ \
--exclude /.github/ \
--exclude /.gitignore \
--exclude /.ssh/ \
--filter=':- /.gitignore' \
wp-content/plugins/ "$INSTALL@$SSH_HOST:/sites/$INSTALL/wp-content/plugins"
deploy-muplugins:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_muplugins }}
needs: [ backup-muplugins ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy mu-plugins
run: |
rsync -chavP --stats \
-e 'ssh -i ~/.ssh/deploy-wpengine' \
--exclude /.git/ \
--exclude /.github/ \
--exclude /.gitignore \
--exclude /.ssh/ \
--filter=':- /.gitignore' \
wp-content/mu-plugins/ "$INSTALL@$SSH_HOST:/sites/$INSTALL/wp-content/mu-plugins"
deploy-themes:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_themes }}
needs: [ backup-themes ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy themes
run: |
rsync -chavP --delete --stats \
-e 'ssh -i ~/.ssh/deploy-wpengine' \
--exclude /.git/ \
--exclude /.github/ \
--exclude /.gitignore \
--exclude /.ssh/ \
--filter=':- /.gitignore' \
wp-content/themes/ "$INSTALL@$SSH_HOST:/sites/$INSTALL/wp-content/themes"
what-git-branch:
runs-on: ubuntu-latest
needs: [ deploy-plugins, deploy-muplugins, deploy-themes, deploy-root ]
if: ${{ always() && contains( needs.*.result, 'success' ) }}
steps:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Set branch name
run: |
echo ${GITHUB_REF#refs/heads/} > .what-git-branch
cat .what-git-branch
scp -i ~/.ssh/deploy-wpengine .what-git-branch "$INSTALL@$SSH_HOST:/sites/$INSTALL/"
clear-caches:
runs-on: ubuntu-latest
needs: [ deploy-plugins, deploy-muplugins, deploy-themes, deploy-root ]
if: ${{ always() && contains( needs.*.result, 'success' ) }}
steps:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.0
with:
private-key: ${{ secrets.WPENGINE_SSH_KEY_PRIVATE }}
private-key-name: deploy-wpengine
known-hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Clear caches
run: ssh -i ~/.ssh/deploy-wpengine $INSTALL@$SSH_HOST 'wp cache flush; wp page-cache flush; wp cdn-cache flush'