-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (203 loc) · 9.2 KB
/
Copy pathdeployments.yml
File metadata and controls
227 lines (203 loc) · 9.2 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: Deploy to WP Engine
on:
workflow_dispatch:
push:
branches:
- main
- staging
- develop
env:
DEV_BRANCH: develop
STG_BRANCH: staging
PRD_BRANCH: main
DEV_ENV: berkhamcounsdev
STG_ENV: berkhamcounsstg
PRD_ENV: berkhamcouns
permissions:
contents: write
deployments: write
statuses: write
jobs:
check-project:
name: Pre-deploy checks
runs-on: ubuntu-latest
env:
DEV_ENV_SECRET: ${{ secrets.DEV_ENV }}
STG_ENV_SECRET: ${{ secrets.STG_ENV }}
PRD_ENV_SECRET: ${{ secrets.PRD_ENV }}
steps:
- name: Check this is a client project
if: github.repository == 'indigotree/platform-skeleton'
run: exit 1
- name: Check project has its environment name set
if: contains(env.DEV_ENV, 'CHANGE_ME') || contains(env.STG_ENV, 'CHANGE_ME') || contains(env.PRD_ENV, 'CHANGE_ME')
run: exit 1
- name: Check deployment targets match GitHub configuration
if: env.DEV_ENV != env.DEV_ENV_SECRET || env.STG_ENV != env.STG_ENV_SECRET || env.PRD_ENV != env.PRD_ENV_SECRET
run: exit 1
deploy:
name: Deploy
needs: check-project
concurrency: ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node JS
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
tools: composer:v2
coverage: none
- name: Install Dependencies (JS)
run: npm ci
- name: Install Dependencies (PHP)
uses: ramsey/composer-install@v2
env:
COMPOSER_AUTH: ${{ secrets.PLATFORM_COMPOSER_AUTH }}
with:
composer-options: "--no-dev --optimize-autoloader"
- name: Build assets
run: npm run build
- name: Set WPE_ENV from target branch
run: |
TARGET="${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}"
if [ "$TARGET" = "${{ env.DEV_BRANCH }}" ]; then
echo "WPE_ENV=${{ env.DEV_ENV }}" >> $GITHUB_ENV
elif [ "$TARGET" = "${{ env.STG_BRANCH }}" ]; then
echo "WPE_ENV=${{ env.STG_ENV }}" >> $GITHUB_ENV
elif [ "$TARGET" = "${{ env.PRD_BRANCH }}" ]; then
echo "WPE_ENV=${{ env.PRD_ENV }}" >> $GITHUB_ENV
else
echo "WPE_ENV=example" >> $GITHUB_ENV
fi
- name: Create release on Github
id: create_deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/{repository}/deployments
repository: ${{ github.repository }}
ref: ${{ github.ref_name }}
environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name }}
auto_merge: false
required_contexts: "[]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Set deployment status to in progress
id: start_deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/{repository}/deployments/{deployment}/statuses
repository: ${{ github.repository }}
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
description: Deploying ${{ github.sha }} to the ${{ github.ref_name }} environment.
state: in_progress
required_contexts: "[]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Deploy plugins
uses: wpengine/github-action-wpe-site-deploy@v3
with:
# Deploy vars
CACHE_CLEAR: FALSE
FLAGS: "-azvr --inplace --verbose --ignore-existing --exclude-from=.deployignore"
WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
WPE_ENV: ${{ env.WPE_ENV }}
# PATHS:
SRC_PATH: "wp-content/plugins"
REMOTE_PATH: "wp-content"
# Branches & environments
DEV_BRANCH: ${{ env.DEV_BRANCH }}
STG_BRANCH: ${{ env.STG_BRANCH }}
PRD_BRANCH: ${{ env.PRD_BRANCH }}
DEV_ENV: ${{ env.DEV_ENV }}
STG_ENV: ${{ env.STG_ENV }}
PRD_ENV: ${{ env.PRD_ENV }}
- name: Deploy (modules)
uses: wpengine/github-action-wpe-site-deploy@v3
with:
# Deploy vars
CACHE_CLEAR: FALSE
FLAGS: "-azvr --inplace --verbose --delete --delete-delay --exclude-from=.deployignore"
WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
WPE_ENV: ${{ env.WPE_ENV }}
# PATHS:
SRC_PATH: "wp-content/platform"
REMOTE_PATH: "wp-content"
# Branches & environments
DEV_BRANCH: ${{ env.DEV_BRANCH }}
STG_BRANCH: ${{ env.STG_BRANCH }}
PRD_BRANCH: ${{ env.PRD_BRANCH }}
DEV_ENV: ${{ env.DEV_ENV }}
STG_ENV: ${{ env.STG_ENV }}
PRD_ENV: ${{ env.PRD_ENV }}
- name: Deploy (theme, and everything else)
uses: wpengine/github-action-wpe-site-deploy@v3
with:
# Deploy vars
CACHE_CLEAR: TRUE
FLAGS: >-
-azvr --inplace --verbose
--exclude-from=.deployignore
--exclude='/*.*'
--exclude=_wpeprivate/
--exclude=wp-admin/
--exclude=wp-includes/
--exclude=wp-content/plugins/
--exclude=wp-content/platform/
--exclude=wp-content/mu-plugins/
--exclude=wp-content/uploads/
--exclude=wp-content/upgrade*/
--exclude=wp-content/drop-ins/
--exclude=wp-content/languages/
--exclude=mysql.sql
--include='/wp-content/themes/'
--include='/wp-content/themes/indigotree-theme-2025/***'
--exclude='/wp-content/themes/*'
WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
WPE_ENV: ${{ env.WPE_ENV }}
# PATHS:
SRC_PATH: "."
REMOTE_PATH: ""
# Branches & environments
DEV_BRANCH: ${{ env.DEV_BRANCH }}
STG_BRANCH: ${{ env.STG_BRANCH }}
PRD_BRANCH: ${{ env.PRD_BRANCH }}
DEV_ENV: ${{ env.DEV_ENV }}
STG_ENV: ${{ env.STG_ENV }}
PRD_ENV: ${{ env.PRD_ENV }}
- name: Set deployment status to success
id: successful_deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/{repository}/deployments/{deployment}/statuses
repository: ${{ github.repository }}
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
description: Deployed ${{ github.sha }} to the ${{ github.ref_name }} environment.
state: success
required_contexts: "[]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Set deployment status to failure
id: failed_deployment
uses: octokit/request-action@v2.x
if: failure()
with:
route: POST /repos/{repository}/deployments/{deployment}/statuses
repository: ${{ github.repository }}
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: failure
required_contexts: "[]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"