forked from Azure/azure-resource-manager-schemas
-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (114 loc) · 3.64 KB
/
generate-schemas.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
name: Generate Schemas
on:
schedule:
- cron: '45 5 * * TUE,THU'
workflow_dispatch:
inputs:
api_specs_ref:
description: 'Git ref or full SHA for https://github.com/Azure/azure-rest-api-specs.'
required: true
default: 'main'
env:
# This must be kept in sync with the arguments passed to the "batch" matrix
BATCH_COUNT: 20
jobs:
generate:
name: Update Schemas Batch ${{ matrix.batch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
batch: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Clone azure-rest-api-specs
uses: actions/checkout@v4
with:
repository: Azure/azure-rest-api-specs
path: workflow-temp/azure-rest-api-specs
ref: ${{ github.event.inputs.api_specs_ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install generator npm packages
run: npm ci
working-directory: generator
- name: Build bicep-types
run: |
npm ci
npm run build
working-directory: bicep-types-az/bicep-types/src/bicep-types
- name: Build autorest.bicep
run: |
npm ci
npm run build
working-directory: bicep-types-az/src/autorest.bicep
- name: Run generator
run: |
set -e
rm -Rf "$GITHUB_WORKSPACE/schemas"
rm -Rf "$GITHUB_WORKSPACE/summary.log"
mkdir -p "$GITHUB_WORKSPACE/schemas"
npm run generate-all -- \
--specs-dir "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \
--batch-count ${{ env.BATCH_COUNT }} \
--batch-index ${{ matrix.batch }} \
--summary-log-path "$GITHUB_WORKSPACE/summary.log" \
--combine-batch-mode true
working-directory: generator
- name: Write summary
if: ${{ always() }}
run: cat summary.log >> $GITHUB_STEP_SUMMARY
- name: Upload Schemas
uses: actions/upload-artifact@v4
with:
name: batch-${{ matrix.batch }}-schemas
path: schemas
if-no-files-found: error
- name: Upload summary log
uses: actions/upload-artifact@v4
with:
name: batch-${{ matrix.batch }}-summary
path: summary.log
if-no-files-found: error
combine:
needs: generate
name: Combine Schema Batches
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Download batch results
uses: actions/download-artifact@v4
with:
path: workflow-temp
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install generator npm packages
run: npm ci
working-directory: generator
- name: Combine batches
run: |
npm run combine-batches -- \
--input-path "$GITHUB_WORKSPACE/workflow-temp" \
--batch-count ${{ env.BATCH_COUNT }}
working-directory: generator
- name: Update resources.json
run: |
npm run list-resources
working-directory: generator
- name: Push to autogenerate-batch branch
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update Generated Schemas
branch: autogenerate-batch
push_options: '--force'
create_branch: true