-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (132 loc) · 7.63 KB
/
check-openapi-generator-update.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
# cspell:ignore dblock elif fjogeleit openapitools Wandalen wretry
name: openapi-generatorのバージョンアップ確認
on:
pull_request:
branches: [main]
paths:
- '.github/workflows/check-openapi-generator-update.yml'
workflow_dispatch:
schedule:
- cron: '0 22 * * 0'
permissions:
contents: read
issues: write
jobs:
check-update:
name: openapi-generatorのバージョンアップ確認
runs-on: ubuntu-latest
steps:
- name: GitHub API経由でリポジトリの情報を取得
id: get-repo-info-via-github-api
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.github.com/repos/OpenAPITools/openapi-generator/releases/latest'
method: 'GET'
customHeaders: '{"Content-Type": "application/json"}'
- name: 最新のOpenAPI Generatorのバージョン取得
id: get-latest-openapi-generator-version
run: |
echo ${{ steps.get-repo-info-via-github-api.outputs.response }}
echo ${{ steps.get-repo-info-via-github-api.outputs.headers }}
echo ${{ steps.get-repo-info-via-github-api.outputs.status }}
echo "latest-version=$(echo ${{ fromJson(steps.get-repo-info-via-github-api.outputs.response).tag_name }} |sed 's/^v//')" >> $GITHUB_OUTPUT
- name: チェックアウト
uses: actions/checkout@v4
- name: 現在のOpenAPI Generatorのバージョン取得
id: get-current-openapi-generator-version
run: |
echo "current-version-consumer=$(jq -r '.["generator-cli"].version' ./samples/web-csr/dressca-frontend/consumer/openapitools.json)" >> $GITHUB_OUTPUT
echo "current-version-admin=$(jq -r '.["generator-cli"].version' ./samples/web-csr/dressca-frontend/admin/openapitools.json)" >> $GITHUB_OUTPUT
- name: アップデート要否を判定
id: check-version-update
run: |
if [[ ${{ steps.get-latest-openapi-generator-version.outputs.latest-version }} == ${{ steps.get-current-openapi-generator-version.outputs.current-version-consumer }} ]]; then
echo "update-required-consumer=false" >> $GITHUB_OUTPUT
else
echo "update-required-consumer=true" >> $GITHUB_OUTPUT
fi
if [[ ${{ steps.get-latest-openapi-generator-version.outputs.latest-version }} == ${{ steps.get-current-openapi-generator-version.outputs.current-version-admin }} ]]; then
echo "update-required-admin=false" >> $GITHUB_OUTPUT
else
echo "update-required-admin=true" >> $GITHUB_OUTPUT
fi
- name: サマリに出力
run: |
echo "# 確認結果" >> $GITHUB_STEP_SUMMARY
echo "openapi-generator のバージョンは ${{ steps.get-latest-openapi-generator-version.outputs.latest-version }} です。" >> $GITHUB_STEP_SUMMARY
echo "## Dressca-Consumer" >> $GITHUB_STEP_SUMMARY
echo "openapitools.json の openapi-generator のバージョンは ${{ steps.get-current-openapi-generator-version.outputs.current-version-consumer }} です。" >> $GITHUB_STEP_SUMMARY
echo "アップデート要否の判定結果は ${{ steps.check-version-update.outputs.update-required-consumer }} です。">> $GITHUB_STEP_SUMMARY
echo "## Dressca-Admin" >> $GITHUB_STEP_SUMMARY
echo "openapitools.json の openapi-generator のバージョンは ${{ steps.get-current-openapi-generator-version.outputs.current-version-admin }} です。" >> $GITHUB_STEP_SUMMARY
echo "アップデート要否の判定結果は ${{ steps.check-version-update.outputs.update-required-admin }} です。">> $GITHUB_STEP_SUMMARY
- name: issue を作成(Dressca-Consumer)
id: create-issue-consumer
if: ${{ steps.check-version-update.outputs.update-required-consumer == 'true' }}
uses: Wandalen/wretry.action@master
with:
action: dblock/create-a-github-issue@v3
with: |
filename: ./.github/ISSUE_TEMPLATE/99-openapi-generator-update-issue.md
update_existing: true
search_existing: open
attempt_limit: 3
attempt_delay: 300000
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_APP_NAME: "Dressca-Consumer"
LATEST_VERSION: ${{ steps.get-latest-openapi-generator-version.outputs.latest-version }}
CURRENT_VERSION: ${{ steps.get-current-openapi-generator-version.outputs.current-version-consumer }}
- name: issue の情報を出力(Dressca-Consumer)
if: ${{ steps.check-version-update.outputs.update-required-consumer == 'true' }}
env:
STATUS: ${{ steps.create-issue-consumer.outputs.outputs && fromJson(steps.create-issue-consumer.outputs.outputs).status }}
ISSUE_NUMBER: ${{ steps.create-issue-consumer.outputs.outputs && fromJson(steps.create-issue-consumer.outputs.outputs).number }}
ISSUE_URL: ${{ steps.create-issue-consumer.outputs.outputs && fromJson(steps.create-issue-consumer.outputs.outputs).url }}
run: |
echo "# issue の作成結果(Dressca-Consumer)" >> $GITHUB_STEP_SUMMARY
if [ $STATUS = 'created' ]; then
echo "issue を新規作成しました。" >> $GITHUB_STEP_SUMMARY
elif [ $STATUS = 'updated' ]; then
echo "同名の issue が存在するため、更新のみ行いました。" >> $GITHUB_STEP_SUMMARY
else
echo "ステータスの値が不正です。" >> $GITHUB_STEP_SUMMARY
fi
echo issue number: $ISSUE_NUMBER >> $GITHUB_STEP_SUMMARY
echo status: $STATUS >> $GITHUB_STEP_SUMMARY
echo - $ISSUE_URL >> $GITHUB_STEP_SUMMARY
- name: issue を作成(Dressca-Admin)
id: create-issue-admin
if: ${{ steps.check-version-update.outputs.update-required-admin == 'true' }}
uses: Wandalen/wretry.action@master
with:
action: dblock/create-a-github-issue@v3
with: |
filename: ./.github/ISSUE_TEMPLATE/99-openapi-generator-update-issue.md
update_existing: true
search_existing: open
attempt_limit: 3
attempt_delay: 300000
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_APP_NAME: "Dressca-Admin"
LATEST_VERSION: ${{ steps.get-latest-openapi-generator-version.outputs.latest-version }}
CURRENT_VERSION: ${{ steps.get-current-openapi-generator-version.outputs.current-version-admin }}
- name: issue の情報を出力(Dressca-Admin)
if: ${{ steps.check-version-update.outputs.update-required-admin == 'true' }}
env:
STATUS: ${{ steps.create-issue-admin.outputs.outputs && fromJson(steps.create-issue-admin.outputs.outputs).status }}
ISSUE_NUMBER: ${{ steps.create-issue-admin.outputs.outputs && fromJson(steps.create-issue-admin.outputs.outputs).number }}
ISSUE_URL: ${{ steps.create-issue-admin.outputs.outputs && fromJson(steps.create-issue-admin.outputs.outputs).url }}
run: |
echo "# issue の作成結果(Dressca-Admin)" >> $GITHUB_STEP_SUMMARY
if [ $STATUS = 'created' ]; then
echo "issue を新規作成しました。" >> $GITHUB_STEP_SUMMARY
elif [ $STATUS = 'updated' ]; then
echo "同名の issue が存在するため、更新のみ行いました。" >> $GITHUB_STEP_SUMMARY
else
echo "ステータスの値が不正です。" >> $GITHUB_STEP_SUMMARY
fi
echo issue number: $ISSUE_NUMBER >> $GITHUB_STEP_SUMMARY
echo status: $STATUS >> $GITHUB_STEP_SUMMARY
echo - $ISSUE_URL >> $GITHUB_STEP_SUMMARY