-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (225 loc) · 8.92 KB
/
build-and-release-documents.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
---
# cSpell:ignore endgroup fjogeleit markdownlint softprops textlintrc webapps
name: ドキュメントのビルドとリリース
on:
push:
branches: [main]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-Beta[0-9]+'
pull_request:
branches: [main]
paths:
- 'documents/**'
- 'iis-files/**'
- 'samples/**'
- '.github/workflows/build-and-release-documents.yml'
- '.markdownlint.yaml'
- '.textlintrc'
- '.yaml-lint.yml'
- 'package-lock.json'
- 'package.json'
- 'requirements.txt'
workflow_dispatch:
permissions:
id-token: write
contents: write
env:
APP_ALESINFINY_MAIA_WEBAPP_NAME: app-alesinfiny-maia-docs-prod
DOCUMENT_ARTIFACTS_FILENAME: docs.zip
jobs:
build:
name: ドキュメントのビルド
runs-on: ubuntu-latest
outputs:
is_pre_release: ${{ steps.setup-variables.outputs.is_pre_release }}
steps:
- id: setup-variables
name: 変数の初期化
run: |
pre_release=false
if [[ "${{ github.ref_name }}" == *"Beta"* ]]; then
pre_release=true
fi
echo "is_pre_release:$pre_release"
echo "is_pre_release=$pre_release" >> $GITHUB_ENV
echo "is_pre_release=$pre_release" >> $GITHUB_OUTPUT
- name: ブランチのチェックアウト
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Node.js のセットアップ
uses: actions/setup-node@v4
with:
node-version: 18
- name: npm パッケージのインストール
run: npm ci
- name: Python のセットアップ
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: pip パッケージのインストール
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Linter の処理開始
run: echo '# Linter Result :newspaper:' >> $GITHUB_STEP_SUMMARY
- name: Markdownlint の実行
id: run-markdownlint
continue-on-error: true
run: |
echo '## Markdownlint Result' >> $GITHUB_STEP_SUMMARY
npx markdownlint --config .markdownlint.yaml --ignore **/node_modules/** --output markdownlint-result.txt .
echo ':heavy_check_mark: Markdownlint に成功しました。' >> $GITHUB_STEP_SUMMARY
- name: Markdownlint 失敗時の結果表示
if: ${{ steps.run-markdownlint.outcome == 'failure' }}
run: |
echo ':x: Markdownlint に失敗しました。 ' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat markdownlint-result.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'LINT_STATUS=Error' >> $GITHUB_ENV
- name: yamllint の実行
id: run-yamllint
continue-on-error: true
run: |
echo '## yamllint Result' >> $GITHUB_STEP_SUMMARY
yamllint --config-file .yaml-lint.yml --format standard . > yamllint-result.txt
echo ':heavy_check_mark: yamllint に成功しました。' >> $GITHUB_STEP_SUMMARY
- name: yamllint 失敗時の結果表示
if: ${{ steps.run-yamllint.outcome == 'failure' }}
run: |
echo ':x: yamllint に失敗しました。 ' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat yamllint-result.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'LINT_STATUS=Error' >> $GITHUB_ENV
- name: textlint の実行
run: |
echo '## textlint Result' >> $GITHUB_STEP_SUMMARY
npx textlint documents samples --output-file textlint-result.txt --format compact
if [ -f textlint-result.txt ]; then
echo ':x: textlint に失敗しました。 ' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat textlint-result.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'LINT_STATUS=Error' >> $GITHUB_ENV
else
echo ':heavy_check_mark: textlint に成功しました。' >> $GITHUB_STEP_SUMMARY
fi
- name: Lint 結果の確認
if: ${{ env.LINT_STATUS == 'Error' }}
run: exit 1
- name: dressca.zip の作成
run: |
cd samples/web-csr
zip -r ../../documents/contents/samples/downloads/dressca.zip *
- name: azure-ad-b2c.zipの作成
run: |
cd samples/azure-ad-b2c-sample
zip -r ../../documents/contents/samples/downloads/azure-ad-b2c.zip *
- name: ドキュメントのビルド
id: build_documents
continue-on-error: true
run: |
if [ ${{ startsWith(github.ref, 'refs/tags/v') }} ];
then
export VERSION="${{ github.ref_name }}"
else
export VERSION="Test Version"
fi
cd documents
echo '# Mkdocs Build Result :factory:' >> $GITHUB_STEP_SUMMARY
mkdocs build --verbose --clean --strict > mkdocs_build_log.txt
- name: ドキュメントビルドの結果表示(成功)
if: ${{ steps.build_documents.outcome == 'success' }}
run: |
echo ':heavy_check_mark: mkdocs のビルドに成功しました。' >> $GITHUB_STEP_SUMMARY
cd documents
if [ -s mkdocs_build_log.txt ]; then
echo '```' >> $GITHUB_STEP_SUMMARY
cat mkdocs_build_log.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
- name: ドキュメントビルドの結果表示(失敗)
if: ${{ steps.build_documents.outcome == 'failure' }}
run: |
echo ':x: mkdocs のビルドに失敗しました。' >> $GITHUB_STEP_SUMMARY
cd documents
if [ -s mkdocs_build_log.txt ]; then
echo '```' >> $GITHUB_STEP_SUMMARY
cat mkdocs_build_log.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
exit 1
- name: IIS 用のファイル配置とパッケージング
run: |
cp -T -v -f -r iis-files documents/build-artifacts/
cd documents/build-artifacts
zip -r ../${{ env.DOCUMENT_ARTIFACTS_FILENAME }} *
- name: ビルドアーティファクトのアップロード
uses: actions/upload-artifact@v4
with:
name: documents
path: documents/${{ env.DOCUMENT_ARTIFACTS_FILENAME }}
retention-days: 7
release-github:
name: Githubのリリース
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: ビルドアーティファクトのダウンロード
uses: actions/download-artifact@v4
with:
name: documents
- name: Githubのリリース
uses: softprops/action-gh-release@v2
with:
files: ${{ env.DOCUMENT_ARTIFACTS_FILENAME }}
generate_release_notes: true
prerelease: ${{ needs.build.outputs.is_pre_release }}
release-documents:
name: ドキュメントのリリース
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: ビルドアーティファクトのダウンロード
uses: actions/download-artifact@v4
with:
name: documents
- name: Azure に OIDC Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: ステージング環境へのデプロイ
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.APP_ALESINFINY_MAIA_WEBAPP_NAME }}
slot-name: staging
package: '${{ env.DOCUMENT_ARTIFACTS_FILENAME }}'
- name: Teams への通知
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.ALESINFINY_POST_MESSAGE_TO_TEAMS_URL }}
method: POST
contentType: application/json
data: '{"messageType": 0,"branchName": "${{ github.ref }}","actor": "${{ github.actor }}","sha": "${{ github.sha }}","eventName": "${{ github.event_name }}"}'
timeout: 30000
swap:
name: 本番環境への反映承認
needs: [release-github, release-documents]
if: needs.build.outputs.is_pre_release == 'false' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: 本番環境への反映承認
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.ALESINFINY_APPROVE_REQUEST_TO_TEAMS_URL }}
method: POST
contentType: application/json
data: '{"branchName": "${{ github.ref }}","actor": "${{ github.actor }}","sha": "${{ github.sha }}","eventName": "${{ github.event_name }}"}'
preventFailureOnNoResponse: true