-
Notifications
You must be signed in to change notification settings - Fork 89
200 lines (170 loc) · 5.22 KB
/
ci.yml
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
name: GeneratePress CI
on:
workflow_dispatch:
inputs:
name:
description: 'Package name'
default: 'generatepress'
required: true
build-package:
type: boolean
default: false
description: Build the zip package
push:
branches:
- master
pull_request:
branches:
- master
- release/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
js-lint:
name: JS Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'js-files'
uses: tj-actions/[email protected]
with:
files: |
src/**/*.js
src/**/*.json
- name: Setup node
if: steps.js-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 14
- name: Download deps
if: steps.js-files.outputs.any_changed == 'true'
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: Lint
if: steps.js-files.outputs.any_changed == 'true'
run: npm run lint:js
js-commit-dist:
name: Commit dist files
runs-on: ubuntu-latest
needs: [js-lint]
if: ${{ 'master' == github.ref_name || startsWith(github.ref_name, 'release/') || startsWith(github.head_ref, 'release/') }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'js-files'
uses: tj-actions/[email protected]
with:
files: |
src/**/*.js
src/**/*.json
- name: Setup node
if: steps.js-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 14
- name: Download deps
if: steps.js-files.outputs.any_changed == 'true'
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: Build files
if: steps.js-files.outputs.any_changed == 'true'
run: npm run build
- name: Commit files
if: steps.js-files.outputs.any_changed == 'true'
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Update dist files'
add: 'assets/dist/'
push: origin HEAD:${{ github.head_ref }}
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['5.6', '7.4', '8.1']
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'php-files'
uses: tj-actions/[email protected]
with:
files: |
**/*.php
- name: Setup PHP
if: steps.php-files.outputs.any_changed == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Download deps
if: steps.php-files.outputs.any_changed == 'true'
uses: ramsey/composer-install@v2
- name: Lint
if: steps.php-files.outputs.any_changed == 'true'
run: composer run-script php
build-package:
name: Build package
runs-on: ubuntu-latest
needs: [js-lint, php-lint]
if: github.event.inputs.build-package == 'true'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: Build files
run: npm run build
- name: Build grunt files
run: npm run grunt:build
- name: Grunt action-package
run: npm run action-package
- name: Build zip package
uses: actions/[email protected]
with:
name: ${{ github.event.inputs.name }}
path: |
package/
retention-days: 1
check-version:
name: Check versions
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'Release:') }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Check readme.txt
if: ${{ !contains(github.event.pull_request.title, '-alpha') && !contains(github.event.pull_request.title, '-beta') && !contains(github.event.pull_request.title, '-rc') }}
run: 'cat readme.txt | grep -w "Stable tag: ${PR_TITLE:9}"'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
- name: Check package.json
run: 'cat package.json | grep -w "\"version\": \"${PR_TITLE:9}\","'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
- name: Check style header
run: 'cat style.css | grep -w "Version: ${PR_TITLE:9}"'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
- name: Check PHP constant
run: "cat functions.php | grep -w \"define( 'GENERATE_VERSION', '${PR_TITLE:9}' );\""
env:
PR_TITLE: ${{ github.event.pull_request.title }}