54 lines (43 loc) · 1.52 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
name: Python code from specs
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FILE_PATH: openapi.json
jobs:
run:
name: Python code from specs in openapi.json
runs-on: ubuntu-latest
steps:
- name: Set file path
run: echo "FILE_PATH=openapi.json" >> "$GITHUB_ENV"
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 5
- name: Check if running the action is needed.
run: echo "API_SPECS_CHANGED=$(git diff --name-only HEAD HEAD~1 | grep $FILE_PATH)" >> "$GITHUB_ENV"
- name: Show variables
run: echo "HI $API_SPECS_CHANGED $FILE_PATH"
- name: Set up Node.js
if: ENV.API_SPECS_CHANGED
uses: actions/setup-node@v3
- name: Remove previously generated code
if: ENV.API_SPECS_CHANGED
run: xargs rm -rf < .openapi-generator/FILES
- name: Generate python code from specs
if: ENV.API_SPECS_CHANGED
run: npx @openapitools/openapi-generator-cli generate -i $FILE_PATH -g python
- name: Create pull request
if: ENV.API_SPECS_CHANGED
uses: peter-evans/create-pull-request@v5
with:
commit-message: feat(MarloweAPIClient):api client update
title: Update MarloweAPIClient to match OpenAPI specs
body: |
This PR updates the MarloweAPIClient project based on the specs described in `openapi.json`
branch: api-client-codegen