-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (233 loc) · 9.68 KB
/
Copy pathrelease-plugin.yml
File metadata and controls
271 lines (233 loc) · 9.68 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Deploy the Release
# Deploy when a new release is created in the Main branch
on:
release:
# Only deploy when the admin publishes/pre-releases from GitHub
branches:
- 'main'
- 'release/**'
types: [released, edited]
jobs:
plugin_tests:
name: "Plugin tests - PHP"
defaults:
run:
shell: bash
env:
# To deploy to the E20R WooCommerce target, set E20R_SSH_SERVER, E20R_SSH_USER, E20R_SSH_PORT,
# E20R_SSH_KEY, and remove traces of the SVN_* variables
# To deploy to the wordpress.org repository, set SVN_USERNAME and SVN_PASSWORD,
# and remove traces of the E20R_SSH_* variables
E20R_PLUGIN_NAME: e20r-members-list
GITHUB_TOKEN: ${{ secrets.GITHUB }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_ACCESS_TOKEN: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
strategy:
matrix:
php_version: [ '7.3', '7.4', '8.0', '8.1' ]
runs-on: ubuntu-18.04
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1
with:
repository: eighty20results/e20r-members-list
# Extract the branch name for all events except for pull requests
- name: Extract branch or tag name
id: branch-name
uses: tj-actions/branch-names@v9
- name: Setup PHP with Composer V2+
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
extensions: mbstring, xdebug
tools: composer:v2
coverage: pcov
- name: Login to Docker HUB
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
- name: Load cached Composer and test related dependencies
uses: actions/cache@v4
id: composer-cache
with:
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache
path: inc/**
- name: Install all needed dependencies for Composer
if: steps.restore-cache.outputs.cache-hit != 'true'
run: make composer-dev
- name: Install all needed WordPress plugin dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make wp-deps
- name: Install all needed dependencies for Docker
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make docker-deps
- name: Run all Standard Tests
run: make tests
- name: Download artifacts
uses: actions/download-artifact@v6
# To create the plugin .zip archive
build_plugin:
name: Build plugin package to the plugin repository (Our License server or WordPress.org)
needs: [plugin_tests]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
# To deploy to the E20R WooCommerce target, set E20R_SSH_SERVER, E20R_SSH_USER, E20R_SSH_PORT,
# E20R_SSH_KEY, and remove traces of the SVN_* variables
# To deploy to the wordpress.org repository, set SVN_USERNAME and SVN_PASSWORD,
# and remove traces of the E20R_SSH_* variables
E20R_PLUGIN_NAME: e20r-members-list
GITHUB_TOKEN: ${{ secrets.GITHUB }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_ACCESS_TOKEN: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1
with:
repository: eighty20results/e20r-members-list
- name: Install SSH Key
if: ${{ env.E20R_SSH_SERVER }}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding deployment target to known_hosts file
if: ${{ env.E20R_SSH_SERVER }}
run: ssh-keyscan -H -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: "Setup PHP with Composer V2+"
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, xdebug
tools: composer:v2
coverage: pcov
- name: Login to Docker HUB
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
- name: Load cached Composer and test related dependencies
uses: actions/cache@v4
id: composer-cache
with:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache
path: inc/
- name: Install all needed dependencies for Composer
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make composer-dev
- name: Install all needed WordPress plugin dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make wp-deps
- name: Install all needed dependencies for Docker
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make docker-deps
- name: Cache the built plugin package
uses: actions/cache@v4
id: plugin-package-cache
with:
key: ${{ runner.os }}-plugin-package-cache-${{ hashFiles('**/build/kits/**.zip') }}
restore-keys: ${{ runner.os }}-plugin-package-cache
path: build/kits/**.zip
- name: Build and test plugin before deployment
run: make build
# To push the release to the plugin store
release:
name: Deploy package to the plugin repository (Our License server or WordPress.org)
needs: [plugin_tests, build_plugin]
runs-on: ubuntu-18.04
defaults:
run:
shell: bash
env:
# To deploy to the E20R WooCommerce target, set E20R_SSH_SERVER, E20R_SSH_USER, E20R_SSH_PORT,
# E20R_SSH_KEY, and remove traces of the SVN_* variables
# To deploy to the wordpress.org repository, set SVN_USERNAME and SVN_PASSWORD, and remove traces of
# the E20R_SSH_* variables
E20R_PLUGIN_NAME: e20r-members-list
GITHUB_TOKEN: ${{ secrets.GITHUB }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_ACCESS_TOKEN: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1
with:
repository: eighty20results/e20r-members-list
- run: touch ./.am_on_github
- name: Install SSH Key
if: ${{ env.E20R_SSH_SERVER }}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding deployment target to known_hosts file
if: ${{ env.E20R_SSH_SERVER }}
run: ssh-keyscan -H -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Login to Docker HUB
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.CONTAINER_ACCESS_TOKEN }}
- name: Setup PHP with Composer V2+
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, xdebug
tools: composer:v2
coverage: pcov
- name: Load cached Composer and test related dependencies (Production)
uses: actions/cache@v4
id: composer-cache-prod
with:
key: ${{ runner.os }}-composer-cache-prod-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache-prod
path: inc/
- name: Install all needed dependencies for Composer
if: steps.composer-cache-prod.outputs.cache-hit != 'true'
run: make composer-dev
- name: Install all needed WordPress plugin dependencies
if: steps.composer-cache-prod.outputs.cache-hit != 'true'
run: make wp-deps
- name: Install all needed dependencies for Docker
if: steps.composer-cache-prod.outputs.cache-hit != 'true'
run: make docker-deps
- name: Restore the built plugin package
id: plugin-package-cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-plugin-package-cache-${{ hashFiles('**/build/kits/**.zip') }}
restore-keys: ${{ runner.os }}-plugin-package-cache
path: build/kits/**.zip
# Extract the branch name for all events except for pull requests
- name: Decide whether to run deploy action
id: branch-name
uses: tj-actions/branch-names@v9
- name: Show me the branch
run: |
echo "Reference branch is: ${{ steps.branch-name.outputs.ref_branch }}"
echo "Current branch is: ${{ steps.branch-name.outputs.current_branch }}"
echo "Tag is: ${{ steps.branch-name.outputs.tag }}"
echo "Tag state is: '${{ steps.branch-name.outputs.is_tag }}'"
# And then deploy the package if it exists _and_ we're on the main branch with a release tag
# The deployment target will depend on whether the
# E20R_SSH_USER or SVN_USERNAME environment variable is defined
- name: Deploy plugin when building a release (to WooCommerce Store)
if: ${{ env.E20R_SSH_SERVER }}
run: make deploy
env:
BRANCH_NAME: ${{ steps.branch-name.outputs.tag }}
- name: Deploy plugin when building a release (to Wordpress.org repo)
if: ${{ env.SVN_USERNAME }}
run: make deploy
env:
BRANCH_NAME: ${{ steps.branch-name.outputs.tag }}