-
Notifications
You must be signed in to change notification settings - Fork 0
238 lines (212 loc) · 8.14 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
---
# cSpell:ignore endgroup fjogeleit markdownlint softprops textlintrc webapps
name: ドキュメントのビルドとリリース
on: # yamllint disable-line rule:truthy
push:
branches: [main]
tags:
- 'v[0-9]+.[0-9]+.[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'
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
steps:
- name: ブランチのチェックアウト
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Linter の処理開始
run: |
echo '# Linter Result :newspaper:' >> $GITHUB_STEP_SUMMARY
- name: GitHub Super Linter の実行
id: execute_super_linter
continue-on-error: true
uses: github/super-linter/slim@v4
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_INCLUDE: "documents/.*"
LINTER_RULES_PATH: /
MARKDOWN_CONFIG_FILE: '.markdownlint.yaml'
VALIDATE_MARKDOWN: true
VALIDATE_YAML: true
YAML_CONFIG_FILE: '.yaml-lint.yml'
- name: GitHub Super Linter の結果表示
run: |
echo '## GitHub Super linter' >> $GITHUB_STEP_SUMMARY
echo '::group::super-linter.log'
cat super-linter.log
echo '::endgroup::'
LINT_MSG=$(sed '/^$/d' super-linter.log | sed -n -e '/^------/,/^------/p' | sed -n -e '/^[^-]/p' | awk '!a[$0]++{print}')
if [ -n "$LINT_MSG" ]; then
echo ':warning: エラーまたは警告が見つかりました。' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$LINT_MSG" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo ':heavy_check_mark: 成功しました。' >> $GITHUB_STEP_SUMMARY
fi
- name: GitHub Super Linter の処理結果確認
if: ${{ steps.execute_super_linter.outcome == 'failure' }}
run: |
exit 1
- name: npm パッケージのインストール
run: |
npm install
- name: textlint の実行
id: execute_textlint
continue-on-error: true
run: |
echo '## textlint Result' >> $GITHUB_STEP_SUMMARY
npm run textlint-all > textlint-result.txt
echo ':heavy_check_mark: textlint に成功しました。' >> $GITHUB_STEP_SUMMARY
- name: textlint 失敗時の結果表示
if: ${{ steps.execute_textlint.outcome == 'failure' }}
run: |
echo '::group::textlint-result.txt'
cat textlint-result.txt
echo '::endgroup::'
echo ':x: textlint に失敗しました。 ' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat textlint-result.txt | sed -n -e '/problems\?/p' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
exit 1
- name: Python のセットアップ
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: mkdocs のインストール
run: |
python -m pip install --upgrade pip
python -m pip install mkdocs
python -m pip install mkdocs-material
python -m pip install pymdown-extensions
python -m pip install mkdocs-minify-plugin
- name: dressca.zip の作成
run: |
cd samples/web-csr
zip -r ../../documents/contents/samples/downloads/dressca.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@v3
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@v3
with:
name: documents
- name: Githubのリリース
uses: softprops/action-gh-release@v1
with:
files: ${{ env.DOCUMENT_ARTIFACTS_FILENAME }}
generate_release_notes: true
release-documents:
name: ドキュメントのリリース
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: ビルドアーティファクトのダウンロード
uses: actions/download-artifact@v3
with:
name: documents
- name: Azure に OIDC Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: ステージング環境へのデプロイ
uses: azure/webapps-deploy@v2
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: 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