-
Notifications
You must be signed in to change notification settings - Fork 16
130 lines (115 loc) · 5.05 KB
/
Copy pathcodegen.yml
File metadata and controls
130 lines (115 loc) · 5.05 KB
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
name: Weekly Codegen
# Regenerates the auto-generated ES, Cloud and Kibana API bindings against the
# latest upstream `elastic/elastic-client-generator-js` output and, when the
# diff is non-empty, opens a PR. See https://github.com/elastic/cli/issues/79.
on:
schedule:
# Monday 07:00 UTC — matches the cadence of the wider client-codegen suite
# run by elastic/devtools-team (which fires one hour earlier).
- cron: "0 7 * * 1"
workflow_dispatch:
permissions:
contents: read
id-token: write
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
codegen:
name: Regenerate API bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
- name: Install repo dependencies
run: npm ci
# Issued via Vault OIDC. The backing token policy
# (resources/github-token-policies/token-policy-elastic-cli-codegen.yaml
# in elastic/catalog-info) scopes this token to elastic/cli and
# elastic/elastic-client-generator-js — the former so peter-evans can
# push the chore/weekly-codegen branch and open the PR, the latter so
# the generator repo (private) can be cloned.
- name: Fetch ephemeral Github token
id: fetch-token
uses: elastic/ci-gh-actions/fetch-github-token@2feb1c6f5086cf8e06f61ef35e275abed3456f7b # v1.5.3
with:
vault-instance: "ci-prod"
- name: Checkout generator repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
repository: elastic/elastic-client-generator-js
path: elastic-client-generator-js
ref: main
token: ${{ steps.fetch-token.outputs.token }}
persist-credentials: false
- name: Install generator dependencies
working-directory: elastic-client-generator-js
run: npm install --no-audit --no-fund
- name: Regenerate ES bindings
env:
CODEGEN_GENERATOR_DIR: ${{ github.workspace }}/elastic-client-generator-js
run: npm run codegen:es
- name: Regenerate Cloud bindings
env:
CODEGEN_GENERATOR_DIR: ${{ github.workspace }}/elastic-client-generator-js
run: npm run codegen:cloud
- name: Regenerate Kibana bindings
env:
CODEGEN_GENERATOR_DIR: ${{ github.workspace }}/elastic-client-generator-js
run: npm run codegen:kibana
- name: Build
run: npm run build
- name: Unit tests
run: npm run test:unit
- name: Detect generated diff
id: diff
shell: bash
run: |
if git diff --quiet -- src/es src/cloud src/kb; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No generated changes — nothing to PR."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
git --no-pager diff --stat -- src/es src/cloud src/kb
fi
# Reuse the ephemeral token fetched at the start of the job — see the
# "Fetch ephemeral Github token" step above. Using it (vs. GITHUB_TOKEN)
# also means the resulting PR is authored by a non-Actions identity and
# therefore triggers downstream CI (e.g. `ci.yml`).
- name: Create Pull Request
if: steps.diff.outputs.changed == 'true'
id: cpr
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ steps.fetch-token.outputs.token }}
branch: chore/weekly-codegen
delete-branch: true
base: main
commit-message: "chore(codegen): weekly update of generated API bindings"
title: "chore(codegen): weekly update of generated API bindings"
body: |
Automated weekly regeneration of the ES, Cloud and Kibana API
bindings against the latest `elastic/elastic-client-generator-js`
output.
- `src/es/apis/**` — produced by `npm run cli-es`
- `src/es/apis/schemas/**` — produced by `npm run zod`
- `src/es/api-manifest.ts` — copied from `output/es/manifest.ts` (generator)
- `src/cloud/apis/**` and `src/cloud/apis.ts` — produced by `npm run cli-cloud`
- `src/kb/apis/**` — produced by `npx tsx cli/kibana/index.ts`
- `src/kb/api-manifest.ts` — copied from `output/kibana/manifest.ts` (generator)
Run locally with `npm run codegen:es` / `npm run codegen:cloud` /
`npm run codegen:kibana`.
Refs: #79
committer: "elastic-machine <elasticmachine@users.noreply.github.com>"
author: "elastic-machine <elasticmachine@users.noreply.github.com>"
add-paths: |
src/es
src/cloud
src/kb
- name: PR summary
if: steps.cpr.outputs.pull-request-url
shell: bash
run: |
echo "Opened: ${{ steps.cpr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY"