-
Notifications
You must be signed in to change notification settings - Fork 98
262 lines (252 loc) · 12.7 KB
/
deploy.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
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
name: Deploy EC-CUBE2
on:
schedule:
# 水曜日の 00:00 (JST) に処理を実行する
# UTC の 15:00 は JST だと翌日の 00:00
- cron: '0 15 * * 2'
release:
types: [ published ]
jobs:
deploy:
name: Deploy
runs-on: ubuntu-22.04
steps:
- name: PREVIOUS_TAG_NAME
run: |
echo "PREVIOUS_TAG_NAME=$(curl -sS -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: |
echo "LATEST_PRERELEASE_TAG_NAME=$(curl -sS -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/${{ github.repository }}/releases | jq -r 'map(select(.prerelease)) | first | .tag_name')" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: |
echo "LATEST_PRERELEASE_REV=$(curl -sS -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.LATEST_PRERELEASE_TAG_NAME }} | jq -r '.object.sha')" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: |
echo "LATEST_MASTER_REV=$(curl -sS -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/${{ github.repository }}/git/refs/heads/master | jq -r '.object.sha')" >> $GITHUB_ENV
- if: (github.event_name == 'schedule' && env.LATEST_MASTER_REV != env.LATEST_PRERELEASE_REV) || github.event_name == 'release'
run: echo "DEPLOY=1" >> $GITHUB_ENV
- name: TAG_NAME for schedule
if: github.event_name == 'schedule'
run: echo "TAG_NAME=eccube2-weekly-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: TAG_NAME for release
if: github.event_name == 'release'
env:
TAG_NAME: ${{ github.event.release.tag_name }}
run: echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Create Release
if: github.event_name == 'schedule' && env.DEPLOY == 1
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.TAG_NAME }}
name: ${{ env.TAG_NAME }}
body: |
EC-CUBE 2.17系の Weekly build🚀 です。毎週の改善内容を反映しております。
常に安定して動作するよう努めていますが、思わぬ不具合を取り込んでしまっている場合もあります。十分に検証の上ご利用ください。
<table>
<thead><tr><th>File</th><th>Checksum(sha256)</th></tr></thead>
<tbody>
<tr><td><a href="https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.TAG_NAME }}.tar.gz">${{ env.TAG_NAME }}.tar.gz</a></td><td><a href="https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.TAG_NAME }}.tar.gz.checksum.sha256">${{ env.TAG_NAME }}.tar.gz.checksum.sha256</a></td></tr>
<tr><td><a href="https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.TAG_NAME }}.zip">${{ env.TAG_NAME }}.zip</a></td><td><a href="https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/${{ env.TAG_NAME }}.zip.checksum.sha256">${{ env.TAG_NAME }}.zip.checksum.sha256</a></td></tr>
</tbody>
</table>
prerelease: true
- name: RELEASE_BODY
if: github.event_name == 'schedule' && env.DEPLOY == 1
env:
TAG_NAME: ${{ env.TAG_NAME }}
run: |
echo 'RELEASE_BODY<<EOF' >> $GITHUB_ENV
echo $(curl -sS -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.TAG_NAME }} | jq -r .body | sed 's,",\\",g' | sed "s,',,g") >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: RELEASE_ID
if: github.event_name == 'schedule' && env.DEPLOY == 1
env:
TAG_NAME: ${{ env.TAG_NAME }}
run: |
echo "RELEASE_ID=$(curl -sS -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.TAG_NAME }} | jq -r .id)" >> $GITHUB_ENV
- name: GENERATED_NOTES
if: github.event_name == 'schedule' && env.DEPLOY == 1
run: |
echo 'GENERATED_NOTES<<EOF' >> $GITHUB_ENV
echo $(curl -sS -X POST -H 'Accept: application/vnd.github.v3+json' -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/releases/generate-notes -d '{"tag_name":"${{ env.TAG_NAME }}", "previous_tag_name":"${{ env.PREVIOUS_TAG_NAME }}"}' | jq .body | sed 's,",,g' | sed "s,',,g") >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Checkout code
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased' )
uses: actions/checkout@v3
- name: Checkout code
if: github.event_name == 'schedule' && env.DEPLOY == 1
uses: actions/checkout@v3
with:
ref: ${{ env.TAG_NAME }}
- name: Install to Composer
if: env.DEPLOY == 1
run: composer install --no-scripts --no-dev --no-interaction --optimize-autoloader
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
- name: Packaging
if: env.DEPLOY == 1
working-directory: ../
env:
TAG_NAME: ${{ env.TAG_NAME }}
REPOSITORY_NAME: ${{ github.repository }}
run: |
echo $TAG_NAME
echo "remove obsolete files..."
rm -rf $GITHUB_WORKSPACE/.git
rm -rf $GITHUB_WORKSPACE/.gitignore
rm -rf $GITHUB_WORKSPACE/.github
rm -rf $GITHUB_WORKSPACE/.editorconfig
rm -rf $GITHUB_WORKSPACE/.php_cs.dist
rm -rf $GITHUB_WORKSPACE/phpunit.xml.dist
rm -rf $GITHUB_WORKSPACE/phpstan.neon.dist
rm -rf $GITHUB_WORKSPACE/build.xml
rm -rf $GITHUB_WORKSPACE/README.md
rm -rf $GITHUB_WORKSPACE/php.ini
rm -rf $GITHUB_WORKSPACE/phpinicopy.sh
rm -rf $GITHUB_WORKSPACE/phpinidel.sh
rm -rf $GITHUB_WORKSPACE/*.phar
rm -rf $GITHUB_WORKSPACE/setup.sh
rm -rf $GITHUB_WORKSPACE/svn_propset.sh
rm -rf $GITHUB_WORKSPACE/playwright*
rm -rf $GITHUB_WORKSPACE/e2e-tests
rm -rf $GITHUB_WORKSPACE/tests
rm -rf $GITHUB_WORKSPACE/templates
rm -rf $GITHUB_WORKSPACE/patches
rm -rf $GITHUB_WORKSPACE/docs
rm -rf $GITHUB_WORKSPACE/html/test
rm -rf $GITHUB_WORKSPACE/dockerbuild
rm -rf $GITHUB_WORKSPACE/Dockerfile
rm -rf $GITHUB_WORKSPACE/docker-compose*.yml
rm -rf $GITHUB_WORKSPACE/zap
find $GITHUB_WORKSPACE -name "dummy" -print0 | xargs -0 rm -rf
find $GITHUB_WORKSPACE -name ".git*" -and ! -name ".gitkeep" -print0 | xargs -0 rm -rf
find $GITHUB_WORKSPACE -name ".git*" -type d -print0 | xargs -0 rm -rf
echo "set permissions..."
chmod -R o+w $GITHUB_WORKSPACE/html/install/temp
chmod -R o+w $GITHUB_WORKSPACE/html/user_data
chmod -R o+w $GITHUB_WORKSPACE/html/upload
chmod -R o+w $GITHUB_WORKSPACE/data/cache
chmod -R o+w $GITHUB_WORKSPACE/data/downloads
chmod -R o+w $GITHUB_WORKSPACE/data/Smarty
chmod -R o+w $GITHUB_WORKSPACE/data/class
chmod -R o+w $GITHUB_WORKSPACE/data/logs
chmod -R o+w $GITHUB_WORKSPACE/data/upload
chmod -R o+w $GITHUB_WORKSPACE/data/config
chmod o+w $GITHUB_WORKSPACE/html
echo "complession files..."
pwd
ls -al
tar czfp $TAG_NAME.tar.gz ec-cube2
zip -ry $TAG_NAME.zip ec-cube2 1> /dev/null
md5sum $TAG_NAME.tar.gz | awk '{ print $1 }' > $TAG_NAME.tar.gz.checksum.md5
md5sum $TAG_NAME.zip | awk '{ print $1 }' > $TAG_NAME.zip.checksum.md5
sha1sum $TAG_NAME.tar.gz | awk '{ print $1 }' > $TAG_NAME.tar.gz.checksum.sha1
sha1sum $TAG_NAME.zip | awk '{ print $1 }' > $TAG_NAME.zip.checksum.sha1
sha256sum $TAG_NAME.tar.gz | awk '{ print $1 }' > $TAG_NAME.tar.gz.checksum.sha256
sha256sum $TAG_NAME.zip | awk '{ print $1 }' > $TAG_NAME.zip.checksum.sha256
echo "TGZ_SHA256=$(cat $TAG_NAME.tar.gz.checksum.sha256)" >> $GITHUB_ENV
echo "ZIP_SHA256=$(cat $TAG_NAME.zip.checksum.sha256)" >> $GITHUB_ENV
- name: Upload binaries to release of TGZ
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.tar.gz
asset_name: ${{ env.TAG_NAME }}.tar.gz
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of ZIP
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.zip
asset_name: ${{ env.TAG_NAME }}.zip
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of TGZ md5 checksum
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.tar.gz.checksum.md5
asset_name: ${{ env.TAG_NAME }}.tar.gz.checksum.md5
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of TGZ sha1 checksum
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.tar.gz.checksum.sha1
asset_name: ${{ env.TAG_NAME }}.tar.gz.checksum.sha1
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of TGZ sha256 checksum
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.tar.gz.checksum.sha256
asset_name: ${{ env.TAG_NAME }}.tar.gz.checksum.sha256
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of ZIP md5 checksum
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.zip.checksum.md5
asset_name: ${{ env.TAG_NAME }}.zip.checksum.md5
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of ZIP sha1 checksum
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.zip.checksum.sha1
asset_name: ${{ env.TAG_NAME }}.zip.checksum.sha1
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Upload binaries to release of ZIP sha256 checksum
if: env.DEPLOY == 1
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ runner.workspace }}/${{ env.TAG_NAME }}.zip.checksum.sha256
asset_name: ${{ env.TAG_NAME }}.zip.checksum.sha256
tag: ${{ env.TAG_NAME }}
overwrite: true
- name: Update Release notes
if: github.event_name == 'schedule' && env.DEPLOY == 1
run: |
curl -sS \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }} \
-d '{"draft":false, "body":"${{ env.RELEASE_BODY }}\n${{ env.GENERATED_NOTES }}"}'