Skip to content

Commit

Permalink
👷 ci generation
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Dec 26, 2024
1 parent d6e7308 commit d5f732b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/generator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: OpenAPI Client Generator

on:
workflow_dispatch:
push:
branches:
- v2

jobs:
generate:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout Latest Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
- name: Setup Python
uses: actions/setup-python@v3
- name: Install dependencies
run: npm clean-install
- name: Verify NPM Signatures
run: npm audit signatures
- name: Fetch Latest OpenAPI YAML
run: |
npm run spec
- name: Get OpenAPI Version
id: version
uses: mikefarah/yq@master
with:
cmd: cat openapi.yaml | yq -r .info.version
- name: Generate OpenAPI Client
run: npm run generate
- name: Run Pre-Commit
uses: pre-commit/action@v3.0.1
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
add-paths: openapi.yaml,clients
commit-message: ✨ lunchmoney openapi spec v${{ steps.version.outputs.result }}
branch: openapi/v${{ steps.version.outputs.result }}
delete-branch: true
title: ✨ lunchmoney openapi spec v${{ steps.version.outputs.result }}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docker run --rm \
--volume ${PWD}:/work \
--workdir /work \
timbru31/java-node \
/bin/bash -c "npm install && npm run generate"
/bin/bash -c "npm install && npm run spec && npm run generate"
```

### MacOS
Expand All @@ -29,8 +29,9 @@ docker run --rm \
npm install
```

3. Generate Clients
3. Fetch the Latest Spec and Generate Clients

```bash
npm run spec
npm run generate
```
2 changes: 1 addition & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"generators": {
"python": {
"generatorName": "python",
"inputSpec": "https://lm-v2-api-mock-data-f24357049a1b.herokuapp.com/v2/openapi",
"inputSpec": "openapi.yaml",
"output": "clients/python",
"packageName": "lunchable",
"skipValidateSpec": true
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"scripts": {
"openapi-generator-cli": "openapi-generator-cli",
"spec": "curl -LsSf https://lm-v2-api-mock-data-f24357049a1b.herokuapp.com/v2/openapi --output openapi.yaml",
"generate": "openapi-generator-cli generate"
},
"devDependencies": {
Expand Down

0 comments on commit d5f732b

Please sign in to comment.