1
- name : Generate Schemas batch
1
+ name : Generate Schemas Batch
2
2
3
3
on :
4
4
schedule :
5
- - cron : ' 0 1 * * 3 '
5
+ - cron : ' 45 5 * * SUN '
6
6
workflow_dispatch :
7
7
inputs :
8
8
api_specs_ref :
@@ -11,215 +11,106 @@ on:
11
11
default : ' main'
12
12
13
13
env :
14
- SUMMARY_LOG_DIR : /tmp/summary
15
- SUMMARY_LOG_PATH : /tmp/summary/summary.log
16
- SUMMARY_LOG_ARTIFACT_NAME : summary-log
17
- AUTOGENERATE_BRANCH_NAME : autogenerate
18
- TEMP_AUTOGENERATE_BRANCH_NAME : autogenerate_tmp
19
- AUTHOR : ${{ github.actor }}
20
- AUTHOR_EMAIL : ${{ github.actor }}@users.noreply.github.com
14
+ # This must be kept in sync with the arguments passed to the "batch" matrix
15
+ BATCH_COUNT : 20
16
+
21
17
jobs :
22
- batch-0 :
23
- name : Update Schemas Batch 0
18
+ generate :
19
+ name : Update Schemas Batch ${{ matrix.batch }}
24
20
runs-on : ubuntu-latest
21
+ strategy :
22
+ matrix :
23
+ batch : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
25
24
steps :
26
-
27
- with :
28
- ref : ${{ env.AUTOGENERATE_BRANCH_NAME }}
29
-
30
- -
uses :
peterjgrainger/[email protected]
31
- env :
32
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33
- with :
34
- branch : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
25
+ - name : Checkout repo
26
+ uses : actions/checkout@v3
35
27
36
28
- name : Clone azure-rest-api-specs
37
- uses : actions/checkout@v2.3.5
29
+ uses : actions/checkout@v3
38
30
with :
39
31
repository : Azure/azure-rest-api-specs
40
32
path : workflow-temp/azure-rest-api-specs
41
33
ref : ${{ github.event.inputs.api_specs_ref }}
42
-
43
- - name : Install generator npm packages
44
- run : npm ci
45
- working-directory : generator
46
34
47
- - name : Create initial log description
48
- run : mkdir -p /tmp/summary
49
-
50
- - id : generate
51
- name : Run generator
52
- run : |
53
- npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 0
54
- working-directory : generator
55
-
56
- - name : Commit changes
57
- uses : EndBug/add-and-commit@v8
35
+ - name : Setup Node.js
36
+ uses : actions/setup-node@v3
58
37
with :
59
- default_author : github_actor
60
- message : ' Autogenerate schemas batch 0'
61
- new_branch : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
62
-
63
- - name : Upload summary log
64
- uses : actions/upload-artifact@v2
65
- with :
66
- name : ${{ env.SUMMARY_LOG_ARTIFACT_NAME }}
67
- path : ${{ env.SUMMARY_LOG_PATH }}
68
- batch-1 :
69
- needs : batch-0
70
- name : Update Schemas Batch 1
71
- runs-on : ubuntu-latest
72
- steps :
73
-
74
- with :
75
- ref : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
76
-
77
- - name : Clone azure-rest-api-specs
78
-
79
- with :
80
- repository : Azure/azure-rest-api-specs
81
- path : workflow-temp/azure-rest-api-specs
82
- ref : ${{ github.event.inputs.api_specs_ref }}
38
+ node-version : 16.x
83
39
84
40
- name : Install generator npm packages
85
41
run : npm ci
86
42
working-directory : generator
87
43
88
- - name : Download summary log artifact
89
- uses : actions/download-artifact@v2
90
- with :
91
- name : ${{ env.SUMMARY_LOG_ARTIFACT_NAME }}
92
- path : ${{ env.SUMMARY_LOG_DIR }}
93
-
94
- - id : generate
95
- name : Run generator
44
+ - name : Run generator
96
45
run : |
97
- npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 1
46
+ rm -Rf "$GITHUB_WORKSPACE/schemas"
47
+ rm -Rf "$GITHUB_WORKSPACE/summary.log"
48
+ mkdir -p "$GITHUB_WORKSPACE/schemas"
49
+
50
+ npm run generate-all -- \
51
+ --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \
52
+ --batch-count ${{ env.BATCH_COUNT }} \
53
+ --batch-index ${{ matrix.batch }} \
54
+ --summary-log-path "$GITHUB_WORKSPACE/summary.log" \
55
+ --combine-batch-mode true
98
56
working-directory : generator
99
57
100
- - name : Commit changes
101
- uses : EndBug/add-and-commit@v8
58
+ - name : Upload Schemas
59
+ uses : actions/upload-artifact@v3
102
60
with :
103
- default_author : github_actor
104
- message : ' Autogenerate schemas batch 1 '
105
- new_branch : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
61
+ name : batch-${{ matrix.batch }}-schemas
62
+ path : schemas
63
+ if-no-files-found : error
106
64
107
65
- name : Upload summary log
108
- uses : actions/upload-artifact@v2
66
+ uses : actions/upload-artifact@v3
109
67
with :
110
- name : ${{ env.SUMMARY_LOG_ARTIFACT_NAME }}
111
- path : ${{ env.SUMMARY_LOG_PATH }}
112
- batch-2 :
113
- needs : batch-1
114
- name : Update Schemas Batch 2
115
- runs-on : ubuntu-latest
116
- steps :
117
-
118
- with :
119
- ref : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
68
+ name : batch-${{ matrix.batch }}-summary
69
+ path : summary.log
70
+ if-no-files-found : error
120
71
121
- - name : Clone azure-rest-api-specs
122
-
123
- with :
124
- repository : Azure/azure-rest-api-specs
125
- path : workflow-temp/azure-rest-api-specs
126
- ref : ${{ github.event.inputs.api_specs_ref }}
127
-
128
- - name : Install generator npm packages
129
- run : npm ci
130
- working-directory : generator
131
-
132
- - name : Download summary log artifact
133
- uses : actions/download-artifact@v2
134
- with :
135
- name : ${{ env.SUMMARY_LOG_ARTIFACT_NAME }}
136
- path : ${{ env.SUMMARY_LOG_DIR }}
137
-
138
- - id : generate
139
- name : Run generator
140
- run : |
141
- npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 2
142
- working-directory : generator
143
-
144
- - name : Commit changes
145
- uses : EndBug/add-and-commit@v8
146
- with :
147
- default_author : github_actor
148
- message : ' Autogenerate schemas batch 2'
149
- new_branch : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
150
-
151
- - name : Upload summary log
152
- uses : actions/upload-artifact@v2
153
- with :
154
- name : ${{ env.SUMMARY_LOG_ARTIFACT_NAME }}
155
- path : ${{ env.SUMMARY_LOG_PATH }}
156
- batch-3 :
157
- needs : batch-2
158
- name : Update Schemas Batch 3
72
+ combine :
73
+ needs : generate
74
+ name : Combine Schema Batches
159
75
runs-on : ubuntu-latest
160
76
steps :
161
-
77
+ - name : Checkout repo
78
+ uses : actions/checkout@v3
79
+
80
+ - name : Download batch results
81
+ uses : actions/download-artifact@v3
162
82
with :
163
- ref : ${{ env.TEMP_AUTOGENERATE_BRANCH_NAME }}
83
+ path : workflow-temp
164
84
165
- - name : Clone azure-rest-api-specs
166
-
85
+ - name : Setup Node.js
86
+ uses : actions/setup-node@v3
167
87
with :
168
- repository : Azure/azure-rest-api-specs
169
- path : workflow-temp/azure-rest-api-specs
170
- ref : ${{ github.event.inputs.api_specs_ref }}
88
+ node-version : 16.x
171
89
172
90
- name : Install generator npm packages
173
91
run : npm ci
174
92
working-directory : generator
175
93
176
- - name : Download summary log artifact
177
- uses : actions/download-artifact@v2
178
- with :
179
- name : ${{ env.SUMMARY_LOG_ARTIFACT_NAME }}
180
- path : ${{ env.SUMMARY_LOG_DIR }}
181
-
182
- - id : generate
183
- name : Run generator
94
+ - name : Combine batches
184
95
run : |
185
- npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 3
186
-
187
- summary="$(<$SUMMARY_LOG_PATH)"
188
- summary="${summary//'%'/'%25'}"
189
- summary="${summary//$'\n'/'%0A'}"
190
- summary="${summary//$'\r'/'%0D'}"
191
- echo "::set-output name=summary::$summary"
96
+ npm run combine-batches -- \
97
+ --input-path "$GITHUB_WORKSPACE/workflow-temp" \
98
+ --batch-count ${{ env.BATCH_COUNT }}
192
99
working-directory : generator
193
100
194
- - id : get_swagger_gh_uri
195
- name : Get GitHub URI for azure-rest-api-specs
196
- run : |
197
- git_sha=`git rev-parse HEAD`
198
- echo "::set-output name=gh_uri::https://github.com/Azure/azure-rest-api-specs/tree/$git_sha"
199
- working-directory : workflow-temp/azure-rest-api-specs
200
-
201
101
- name : Create Pull Request
202
- uses : peter-evans/create-pull-request@v4.1.3
102
+ uses : peter-evans/create-pull-request@v5
203
103
with :
204
104
committer :
GitHub <[email protected] >
205
- author : ${{ env.AUTHOR }} <${{ env.AUTHOR_EMAIL }}>
105
+ author : ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com >
206
106
signoff : false
207
- branch : main
208
- branch-suffix : short-commit-hash
107
+ branch : autogenerate-batch
209
108
delete-branch : true
210
- token : ${{ secrets.GITHUB_TOKEN }}
211
109
title : |
212
- Update Generated Schemas ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }}
110
+ Update Generated Schemas
213
111
body : |
214
- Update Generated Schemas ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }}
215
-
216
- Generate schemas for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }}
217
-
218
- Summary
219
- ${{ steps.generate.outputs.summary }}
112
+ Update Generated Schemas
220
113
commit-message : |
221
- Update Generated Schemas ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }}
222
-
223
- Generate schemas for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }}
224
- labels : automerge
114
+ Update Generated Schemas
115
+ labels : autogenerate
225
116
draft : false
0 commit comments