-
Notifications
You must be signed in to change notification settings - Fork 0
408 lines (366 loc) · 14.8 KB
/
11checkpingpong.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
name: 11checkpingpong
on:
workflow_run:
workflows: ["01azure_deploy"]
branches: [main]
types:
- completed
push:
branches: [main]
paths:
- senarios/pingpong
jobs:
move_card:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
outputs:
status_cardid: ${{ steps.set_outputs_cardid.outputs.cardid }}
issue_number: ${{ steps.set_outputs_cardid.outputs.issue_number }}
steps:
- uses: actions/checkout@master
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
# Optional, GitHub token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Required, workflow file name or ID
workflow: 01azure_deploy.yml
# Optional, the status or conclusion of a completed workflow to search for
# Can be one of a workflow conclusion::
# "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
# Or a workflow status:
# "completed", "in_progress", "queued"
# Default: "completed,success"
###workflow_conclusion: success
# Optional, will use specified workflow run
#run_id: 1122334455
# Optional, run number from the workflow
#run_number: 34
name: pass_status_cardid
# Optional, directory where to extract artifact
#path: status_cardid.txt
- name: Set the statuses of status_cardid as output parameters
id: set_outputs_cardid
run: |
echo "cat ./status_cardid.txt"
echo "::set-output name=status_cardid::$(<status_cardid.txt)"
echo "::set-output name=issue_number::$(<status_cardid.txt)"
#- name: Create file status_cardid.txt and write the cardid status into it
# id: set_outputs_cardid2
# if: always()
# run: |
# echo ${{ steps.set_outputs_cardid.outputs.issue-number }} > status_cardid.txt
#- name: Upload file status_cardid.txt as an artifact
# if: always()
# uses: actions/upload-artifact@v1
# with:
# name: pass_status_cardid
# path: status_cardid.txt
- name: Create or Update Project Card
uses: peter-evans/create-or-update-project-card@v1
with:
project-name: project01
column-name: checkperformance
issue-number: ${{ steps.set_outputs_cardid.outputs.issue_number }}
pingpong:
runs-on: ubuntu-latest
# 呼び元のworkflowの結果が success であればジョブを実行
# 01azure_deployが成功すれば 11checkpingpong を実施する
#if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs: move_card
if: github.ref == 'refs/heads/main'
env:
MyResourceGroup: tmcbmgt01-hpccicd01
VMPREFIX: hpccicd01
# secret
AZURE_NAME: ${{ secrets.AZURE_NAME }}
AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }}
AZURE_TENANT: ${{ secrets.AZURE_TENANT }}
SSH_SECRET_KEY: ${{ secrets.SSH_SECRET_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
steps:
# スクリプト実行には事前にリポジトリのチェックアウトが必要
- name: Check out repository
uses: actions/checkout@v2
- name: "prep run script1"
run: |
echo "RG: ${MyResourceGroup}"
echo "VMPREFIX: ${VMPREFIX}"
# check environment
uname -a
cat /etc/debian_version
echo "GITHUB_ENV: $GITHUB_ENV"
# actだと必要。github actionsだとPermissionエラーになる
#sudo apt-get -qq update
#sudo apt-get -qq -y install libxml2-utils curl openssh-server
#apt-get -qq -y install curl openssh-server || sudo apt-get -qq -y install curl openssh-server
curl -V
# curl -sL https://aka.ms/InstallAzureCLIDeb | bash
# github actions だとsudoが必要
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az version -o table
- name: "run script"
env:
SSH_SECRET_KEY: ${{ secrets.SSH_SECRET_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
run: |
# 設定ファイル変更反映
bash ./setupcreds.sh hpcbmtenv.sh
# SSH秘密鍵の設定
echo "setting ssh private key...."
echo "$SSH_SECRET_KEY" > ./${VMPREFIX}
md5sum ./${VMPREFIX}
# SSH公開鍵の設定
echo "setting ssh public key...."
echo "$SSH_PUBLIC_KEY" > ./${VMPREFIX}.pub
md5sum ./${VMPREFIX}.pub
grep "MyResourceGroup=" ./hpcbmtenv.sh | head -n 1
grep "VMPREFIX=" ./hpcbmtenv.sh | head -n 1
grep "MAXVM=" ./hpcbmtenv.sh | head -n 1
grep "azure_*" ./hpcbmtenv.sh | head -n 2
# クルデンシャル
sed -i -e 's!^#azure_name="uuid"!azure_name="${{ secrets.AZURE_NAME }}"!' ./hpcbmtenv.sh
sed -i -e 's!^#azure_password="uuid"!azure_password="${{ secrets.AZURE_PASSWORD }}"!' ./hpcbmtenv.sh
sed -i -e 's!^#azure_tenant="uuid"!azure_tenant="${{ secrets.AZURE_TENANT }}"!' ./hpcbmtenv.sh
# スクリプト実行:作成
bash ./hpcbmtenv.sh updatensg
bash ./hpcbmtenv.sh pingpong
if [ ! -f ./result ]; then
echo "::error:: error result file is not found!"
exit 1
fi
cp ./result ./result.txt
- name: Upload test result
uses: actions/upload-artifact@v2.2.3
if: always() # 上記が失敗した場合、デフォルトだと exit 1 でステップが実行されない。 alwaysで実施
with:
name: result.txt
path: result.txt
# 作成された issue をプロジェクトに自動登録
#- name: Creating issue on checkperformance in the project
# uses: imjohnbo/issue-bot@v3.3.0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# title: Check MPI pingpong - ${{ steps.date.outputs.date }}
# assignees: "hirtanak"
# labels: "azurewf01"
# project: 1 # project01, number is 1
# column: "checkperformance"
# milestone: 1
# body: |-
# :wave: Hi,
# cat ./result.txt
# # {{#each assignees}}@{{this}}{{#unless @last}}, {{/unless}}{{/each}}!
# pinned: false
# close-previous: false
# Teamに通知
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: always()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
needs: ${{ toJson(needs) }}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
dry_run: False
- name: Create file status_pingpong.txt and write the job status into it
if: always()
run: |
echo ${{ job.status }} > status_pingpong.txt
- name: Upload file status_pingpong.txt as an artifact
if: always()
uses: actions/upload-artifact@v1
with:
name: pass_status_pingpong
path: status_pingpong.txt
website_build-deploy:
runs-on: ubuntu-latest
needs: pingpong
#if: "!contains(github.event.head_commit.message, 'auto rebuilding site')"
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cloud-sptheme
pip install -r ./docs/requirements.txt
pip install sphinx-autobuild
- name: Set up result (Download)
uses: actions/download-artifact@v2
with:
name: result.txt
path: ./docs/result
- name: Web Site Deploy Configuration
run: |
mkdir ~/.ssh
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
echo "${{ secrets.SSH_SECRET_KEY }}" > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
- name: Web Site Push - Long
env:
GITHUB_USER: "hirtanak"
GITHUB_EMAIL: "hirtanak@gmail.com"
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
git config --local user.name "${GITHUB_USER}"
git config --local user.email "${GITHUB_EMAIL}"
git remote set-url origin git@github.com:${GITHUB_REPOSITORY}.git
git checkout -b gh-pages
git checkout origin/main -- .github/workflows/11checkpingpong.yml
mkdir -p ./tmp/result/
cp ./docs/result/* ./tmp/result/
cp ./docs/index.rst.original ./tmp/index.rst.tmp
cp ./docs/conf.py ./tmp/conf.py
git rm -rf docs # 2.
git commit -m "Removing old subtree"
git subtree add --prefix docs origin gh-pages # 1
# 削除するデータをわざわざ取得するのは冗長に思えるが、git subtree addはgh-pagesブランチへの追跡を行うため必ず実行されなければならない。
# docs/が既に存在する場合はエラーになるため、あらかじめ削除しておくこと。
# 出力先ディレクトリが既存かつ、TypeDocが生成しうるファイル以外のもの(この場合は.nojekyll)が存在するとTypeDocがエラーを起こすため、出力先ディレクトリを削除して後続のコマンドでドキュメントを再作成する。
mkdir -p docs/result
cp ./tmp/result/* ./docs/result/
cp ./tmp/index.rst.tmp ./docs/index.rst.tmp
cp ./tmp/conf.py ./docs/conf.py
rm -rf ./tmp
touch docs/.nojekyll
#wget -q https://raw.githubusercontent.com/hirtanak/hpccicd/gh-pages/docs/index.rst.original -O ./docs/index.rst.tmp
# cp ./docs/index.rst.original ./docs/index.rst.tmp
echo "set up new result file"
#cd ../
ls -la ./
mkdir -p ./docs ./docs/_build
ls -la ./docs/
unset logdate
echo "before"
ls -la ./docs/result/
logdate=$(date "+%Y%m%d_%H%M")
echo $logdate > ./logdate
mv ./docs/result/result.txt ./docs/result/result-${logdate}.rst
echo "after"
ls -la ./docs/result/
ls ./docs/result/* > ./docs/list
# インデックスが重要なためスペース3つ分あけること
sed -i -e "/result\//s/^/ /g" ./docs/list
echo "show ./docs/list"
cat ./docs/list
# ./docs を削除
sed -i -e "s/\.\/docs\/result/\/result/g" ./docs/list
# /result/result.rst を削除
sed -i -e "/\/result\/result.rst/d" ./docs/list
# sed, echo 以外でファイル統合
cat ./docs/index.rst.tmp ./docs/list > ./docs/index.rst
echo "show ./docs/index.rst"
cat ./docs/index.rst
rm ./docs/index.rst.tmp
# Build
sphinx-build -E -b singlehtml ./docs/ docs/_build
# Copy index.html to document root
#rm ./docs/index.html
cp ./docs/_build/index.html ./docs/index.html
#cp -rf ./docs/_build/* ./docs/
cp -rf ./docs/_build ./
git add docs --force
git commit -m "auto build and upload"
git subtree push --prefix docs origin gh-pages
success:
name: pingpong-success_teams_notification
runs-on: ubuntu-18.04
needs: [website_build-deploy]
steps:
- uses: actions/checkout@master
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
needs: ${{ toJson(needs) }}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
dry_run: False
- name: sucuess!
run: |
echo '::success::pingpong and wesite upload was sucuess!'
setup_failure:
name: setup_failure
runs-on: ubuntu-latest
needs: success
steps:
- name: setup_failure
uses: actions/checkout@v2
- name: dummy
run: uname -a
pingpong_failure:
name: pingpong-failure_teams_notification
runs-on: ubuntu-latest
needs: setup_failure
if: always()
outputs:
status_pongpong: ${{ steps.set_outputs_pingpong.outputs.status_pingpong }}
steps:
- uses: actions/checkout@master
- name: Download artifact pass_status_pingpong
uses: actions/download-artifact@v1
with:
name: pass_status_pingpong
- name: Set the statuses of pingpong as output parameters
id: set_outputs_pingpong
run: |
echo "::set-output name=status_pingpong::$(<pass_status_pingpong/status_pingpong.txt)"
echo "::set-output name=pass_status_pingpong::$(<pass_status_pingpong/status_pingpong.txt)"
- name: check_failure
if: steps.set_outputs_pingpong.outputs.status_pingpong == 'failure'
run: |
echo "steps.set_outputs_pingpong.outputs.status_pingpong: ${{ steps.set_outputs_pingpong.outputs.status_pingpong }}"
exit 1
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: failure()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
needs: ${{ toJson(needs) }}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
dry_run: False
move_card2:
runs-on: ubuntu-latest
needs: success
steps:
- uses: actions/checkout@master
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
# Optional, GitHub token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Required, workflow file name or ID
workflow: 01azure_deploy.yml
# Optional, the status or conclusion of a completed workflow to search for
# Can be one of a workflow conclusion::
# "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
# Or a workflow status:
# "completed", "in_progress", "queued"
# Default: "completed,success"
###workflow_conclusion: success
# Optional, will use specified workflow run
#run_id: 1122334455
# Optional, run number from the workflow
#run_number: 34
name: pass_status_cardid
# Optional, directory where to extract artifact
#path: status_cardid.txt
- name: Set the statuses of status_cardid as output parameters
id: set_outputs_cardid
run: |
echo "cat ./status_cardid.txt"
echo "::set-output name=status_cardid::$(<status_cardid.txt)"
echo "::set-output name=issue-number::$(<status_cardid.txt)"
- name: Create or Update Project Card
uses: peter-evans/create-or-update-project-card@v1
with:
project-name: project01
column-name: 'Review in progress'
issue-number: ${{ steps.set_outputs_cardid.outputs.issue-number }}