Skip to content

Commit

Permalink
ci: Add github action to update openapi.json
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jones-dev committed Jun 27, 2024
1 parent c2053d9 commit 216d0f8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/update_openapi_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update openapi.json using openapi.yaml and commit result

on:
pull_request:
branches: [ "main" ]

jobs:
run_conversion:
name: Run convert_to_json.py script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
cd python
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
poetry run convert_to_json ../openapi.yaml ../openapi.json
- name: Commit result
uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
with:
commit_message: Update openapi.json to match openapi.yaml
file_pattern: openapi.json

- if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: echo "Update openapi.json"

- if: steps.auto-commit-action.outputs.changes_detected == 'false'
run: echo "openapi.json is already up to date"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
*.pyc
File renamed without changes.
8 changes: 4 additions & 4 deletions scripts/pyproject.toml → python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tool.poetry]
name = "deepl_openapi"
name = "scripts"
package-mode = false
description = "DeepL OpenAPI specification and associated scripts"
version = "0.1.0"
authors = ["DeepL SE <[email protected]>"]
license = "MIT"
readme = "README.md"

[tool.poetry.scripts]
convert_to_json = "scripts.convert_to_json:main"

[tool.poetry.dependencies]
python = ">=3.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@click.command(
"convert_to_json",
help="Convert OpenAPI YAML to JSON (using std-in and std-out)",
help="Convert OpenAPI YAML to JSON ",
)
@click.argument("input")
@click.argument("output")
Expand Down

0 comments on commit 216d0f8

Please sign in to comment.