-
Notifications
You must be signed in to change notification settings - Fork 316
118 lines (116 loc) · 4.5 KB
/
codegen.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
on:
schedule:
# daily at 12:30 am
- cron: '30 0 * * *'
workflow_dispatch:
name: codegen
jobs:
discovery:
uses: googleapis/discovery-artifact-manager/.github/workflows/list-services.yml@master
batch:
runs-on: ubuntu-22.04
needs: discovery
outputs:
services: ${{ steps.chunk.outputs.result }}
steps:
- uses: actions/github-script@v7
id: chunk
with:
script: |
console.log('splitting service names list into batches')
const services = ${{ needs.discovery.outputs.services }}
const result = {
"one": [],
"two": [],
};
for (let i = 0; i < services.length; i++) {
if (!["discovery", "websecurityscanner"].includes(services[i])) {
j = i < (services.length/2) ? "one" : "two";
result[j].push(services[i])
}
}
return result
generate_batch1:
runs-on: ubuntu-22.04
needs: batch
strategy:
fail-fast: false
max-parallel: 4
matrix:
service: ${{fromJson(needs.batch.outputs.services).one}}
steps:
- run: echo generating ${{ matrix.service }}
- uses: actions/checkout@v4
with:
fetch-depth: 1
path: google-api-php-client-services
- uses: actions/checkout@v4
with:
repository: googleapis/discovery-artifact-manager
fetch-depth: 1
path: discovery-artifact-manager
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- id: find-preferred-versions
run: |
versions=$( cat discovery-artifact-manager/discoveries/index.json | jq -r '[.items[] | select(.name == "${{ matrix.service }}") | select(.name == "admin" or .preferred).version] | join(",")' )
echo "::set-output name=versions::$versions"
- run: ./google-api-php-client-services/.github/workflows/generate.sh ${{ matrix.service }} ${{ steps.find-preferred-versions.outputs.versions }}
- uses: googleapis/code-suggester@v4
env:
ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
with:
command: pr
upstream_owner: ${{ github.repository_owner }}
upstream_repo: google-api-php-client-services
description: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml'
title: 'Regenerate ${{ matrix.service }} client'
message: 'Regenerate ${{ matrix.service }} client'
branch: regenerate-${{ matrix.service }}
git_dir: 'google-api-php-client-services/src'
primary: main
force: true
fork: true
generate_batch2:
runs-on: ubuntu-22.04
needs: batch
strategy:
fail-fast: false
max-parallel: 4
matrix:
service: ${{fromJson(needs.batch.outputs.services).two}}
steps:
- run: echo generating ${{ matrix.service }}
- uses: actions/checkout@v4
with:
fetch-depth: 1
path: google-api-php-client-services
- uses: actions/checkout@v4
with:
repository: googleapis/discovery-artifact-manager
fetch-depth: 1
path: discovery-artifact-manager
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- id: find-preferred-versions
run: |
versions=$( cat discovery-artifact-manager/discoveries/index.json | jq -r '[.items[] | select(.name == "${{ matrix.service }}") | select(.name == "admin" or .preferred).version] | join(",")' )
echo "::set-output name=versions::$versions"
- run: ./google-api-php-client-services/.github/workflows/generate.sh ${{ matrix.service }} ${{ steps.find-preferred-versions.outputs.versions }}
- uses: googleapis/code-suggester@v4
env:
ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
with:
command: pr
upstream_owner: ${{ github.repository_owner }}
upstream_repo: google-api-php-client-services
description: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml'
title: 'Regenerate ${{ matrix.service }} client'
message: 'Regenerate ${{ matrix.service }} client'
branch: regenerate-${{ matrix.service }}
git_dir: 'google-api-php-client-services/src'
primary: main
force: true
fork: true