-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (68 loc) · 2.2 KB
/
generate-sdk.yaml
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
name: Generate SDK Packages
on:
pull_request:
types:
- opened
- synchronize
permissions:
contents: write
jobs:
get-changed-files:
name: Get Changed Files
runs-on: ubuntu-latest
outputs:
oas-modified: ${{ steps.oas-modified.outputs.any_modified }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if `openapi.yaml` has changed
uses: tj-actions/[email protected]
id: oas-modified
with:
files: |
openapi.yaml
generate-js:
name: Generate JavaScript SDK
runs-on: ubuntu-latest
needs: [get-changed-files]
if: needs.get-changed-files.outputs.oas-modified == 'true'
env:
changes_exist: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.ref }}
path: actions
token: ${{ secrets.API_OPS_GH_PAT }}
- name: Build JavaScript SDK
uses: Kong/public-shared-actions/code-build-actions/build-js-sdk@main
with:
app_directory: ${{ github.workspace }}
sdk_output_directory: ${{ github.workspace }}/actions
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if SDK output has changed
shell: bash
working-directory: ${{ github.workspace }}/actions
env:
GH_TOKEN: ${{ secrets.PORTAL_JS_SDK_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
if git diff --exit-code src; then
echo "changes_exist=false" >> $GITHUB_ENV
else
echo "changes_exist=true" >> $GITHUB_ENV
fi
- name: Commit SDK changes to the PR
if: ${{ env.changes_exist == 'true' }}
shell: bash
working-directory: ${{ github.workspace }}/actions
env:
GH_TOKEN: ${{ secrets.PORTAL_JS_SDK_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "team-devx"
gh pr checkout ${{ github.event.pull_request.number }}
git add src/
git commit -m "chore: build SDK from openapi.yaml changes"
git push