-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (169 loc) · 6.84 KB
/
default.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
name: hb
on: [push]
jobs:
build_backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
env:
fail-fast: true
- name: Install deps
run: composer install --ansi
# - name: Run phpstan
# run: composer phpstan
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: backend-deps
path: vendor
build_frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install external deps
run: sudo apt-get install -y pngquant
- name: Install deps
uses: borales/actions-yarn@v5
with:
cmd: install
- name: Build deps
uses: borales/actions-yarn@v5
with:
cmd: build
env:
NODE_ENV: production
- name: Build hb-events
working-directory: ./hb-events
run: |
yarn install
yarn build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: frontend-deps
path: |
UI/AboutStructure/assets/dist
UI/Contacts/assets/dist
UI/Event/assets/dist
UI/Rentals/assets/dist
frontend/dist
hb-events/build
pack:
runs-on: ubuntu-latest
needs:
- build_backend
- build_frontend
steps:
- uses: actions/checkout@v4
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-deps
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-deps
- name: Pack files for release
run: |
zip -r brontosaurus-theme.zip . \
-i "config/*" \
-i "CoordinatesResolver/*" \
-i "DataContainers/*" \
-i "frontend/*" \
-x "frontend/src/*" \
-i "hb-events/*" \
-x "hb-events/src/*" \
-i "log/*" \
-i "Rewrites/*" \
-i "template-parts/*" \
-i "UI/*" \
-x "UI/AboutStructure/assets/src/*" \
-x "UI/Contacts/assets/src/*" \
-x "UI/Event/assets/src/*" \
-x "UI/Rentals/assets/src/*" \
-i "vendor/*" \
-i "ApplicationUrlTemplate.php" \
-i "Assets.php" \
-i "archive-novinky.php" \
-i "bootstrap.php" \
-i "composer.json" \
-i "composer.lock" \
-i "Configuration.php" \
-i "Container.php" \
-i "exceptions.php" \
-i "footer.php" \
-i "functions.php" \
-i "header.php" \
-i "helpers.php" \
-i "index.php" \
-i "PostTypeInitializer.php" \
-i "screenshot.png" \
-i "single-novinky.php" \
-i "style.css"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deps
path: brontosaurus-theme.zip
deploy_staging:
runs-on: ubuntu-latest
if: ${{ ! startsWith(github.ref_name, 'dependabot') }}
needs: pack
environment:
name: staging
url: https://dev.brontosaurus.cz
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: deps
- name: Extract files to deploy
run: |
mkdir -p deploy/files
unzip brontosaurus-theme.zip -d deploy/files
- name: Set up SSH connection
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SERVER_KEYSCAN }}" > ~/.ssh/known_hosts
echo "${{ secrets.KEY_PRIVATE }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.KEY_PUBLIC }}" > ~/.ssh/id_rsa.pub
- name: Deploy
run: |
bash deploy/deploy.sh ${{ secrets.STAGING_REMOTE_USER_AND_HOST }}:${{ secrets.STAGING_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme
ssh ${{ secrets.STAGING_REMOTE_USER_AND_HOST }} "rm -rf ${{ secrets.STAGING_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme/temp/cache"
deploy_production:
runs-on: ubuntu-latest
if: ${{ github.ref_name == 'main' }}
needs: pack
environment:
name: production
url: https://brontosaurus.cz
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: deps
- name: Extract files to deploy
run: |
mkdir -p deploy/files
unzip brontosaurus-theme.zip -d deploy/files
- name: Set up SSH connection
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SERVER_KEYSCAN }}" > ~/.ssh/known_hosts
echo "${{ secrets.KEY_PRIVATE }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.KEY_PUBLIC }}" > ~/.ssh/id_rsa.pub
- name: Deploy
run: |
bash deploy/deploy.sh ${{ secrets.PRODUCTION_REMOTE_USER_AND_HOST }}:${{ secrets.PRODUCTION_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme
ssh ${{ secrets.PRODUCTION_REMOTE_USER_AND_HOST }} "rm -rf ${{ secrets.PRODUCTION_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme/temp/cache"