-
Notifications
You must be signed in to change notification settings - Fork 562
70 lines (67 loc) · 3.01 KB
/
generate-javascript.yml
File metadata and controls
70 lines (67 loc) · 3.01 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
name: Generate
on:
workflow_dispatch:
inputs:
kubernetesBranch:
type: string
required: true
description: 'The remote kubernetes release branch to fetch openapi spec. .e.g. "release-1.23"'
genCommit:
type: string
required: true
default: 'b461333bb57fa2dc2152f939ed70bac3cef2c1f6'
description: 'The commit to use for the kubernetes-client/gen repo'
permissions: {}
jobs:
generate:
runs-on: ubuntu-latest
permissions:
contents: write # Push generated branch
pull-requests: write # Create PR via gh CLI
steps:
- name: Checkout Javascript
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: '20'
- name: Generate Openapi
run: |
echo "export KUBERNETES_BRANCH=${KUBERNETES_BRANCH}" >> ./settings
echo "export GEN_COMMIT=${GEN_COMMIT}" >> ./settings
./generate-client.sh
env:
KUBERNETES_BRANCH: ${{ github.event.inputs.kubernetesBranch }}
GEN_COMMIT: ${{ github.event.inputs.genCommit }}
- name: Generate Branch Name
run: |
SUFFIX=$(openssl rand -hex 4)
echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV
- name: Commit and push
run: |
# Commit and push
git config user.email "k8s.ci.robot@gmail.com"
git config user.name "Kubernetes Prow Robot"
git checkout -b "$BRANCH"
git add .
# we modify the settings file in "Generate Openapi" but do not want to commit this
git reset settings
git commit -s -m "Automated openapi generation from ${KUBERNETES_BRANCH}"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
git push origin "$BRANCH"
env:
KUBERNETES_BRANCH: ${{ github.event.inputs.kubernetesBranch }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request
run: |
gh pr create \
--base "${BASE_BRANCH}" \
--head "$BRANCH" \
--title "Automated Generate from openapi ${KUBERNETES_BRANCH}" \
--body "Automated openapi generation from ${KUBERNETES_BRANCH}"
env:
KUBERNETES_BRANCH: ${{ github.event.inputs.kubernetesBranch }}
BASE_BRANCH: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}