Skip to content

Commit 216d0f8

Browse files
ci: Add github action to update openapi.json
1 parent c2053d9 commit 216d0f8

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

Diff for: .github/workflows/update_openapi_json.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Update openapi.json using openapi.yaml and commit result
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
run_conversion:
9+
name: Run convert_to_json.py script
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Install dependencies
14+
run: |
15+
cd python
16+
python -m pip install --upgrade pip
17+
python -m pip install poetry
18+
poetry install
19+
poetry run convert_to_json ../openapi.yaml ../openapi.json
20+
21+
- name: Commit result
22+
uses: stefanzweifel/git-auto-commit-action@v5
23+
id: auto-commit-action
24+
with:
25+
commit_message: Update openapi.json to match openapi.yaml
26+
file_pattern: openapi.json
27+
28+
- if: steps.auto-commit-action.outputs.changes_detected == 'true'
29+
run: echo "Update openapi.json"
30+
31+
- if: steps.auto-commit-action.outputs.changes_detected == 'false'
32+
run: echo "openapi.json is already up to date"

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea/
2+
*.pyc

Diff for: scripts/poetry.lock renamed to python/poetry.lock

File renamed without changes.

Diff for: scripts/pyproject.toml renamed to python/pyproject.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[tool.poetry]
2-
name = "deepl_openapi"
2+
name = "scripts"
3+
package-mode = false
34
description = "DeepL OpenAPI specification and associated scripts"
4-
version = "0.1.0"
5-
authors = ["DeepL SE <[email protected]>"]
65
license = "MIT"
7-
readme = "README.md"
86

7+
[tool.poetry.scripts]
8+
convert_to_json = "scripts.convert_to_json:main"
99

1010
[tool.poetry.dependencies]
1111
python = ">=3.7"

Diff for: scripts/convert_to_json.py renamed to python/scripts/convert_to_json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@click.command(
77
"convert_to_json",
8-
help="Convert OpenAPI YAML to JSON (using std-in and std-out)",
8+
help="Convert OpenAPI YAML to JSON ",
99
)
1010
@click.argument("input")
1111
@click.argument("output")

0 commit comments

Comments
 (0)