diff --git a/.github/workflows/update_openapi_json.yml b/.github/workflows/update_openapi_json.yml new file mode 100644 index 0000000..1dc7b9a --- /dev/null +++ b/.github/workflows/update_openapi_json.yml @@ -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" diff --git a/.gitignore b/.gitignore index 9f11b75..ee40bb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +*.pyc \ No newline at end of file diff --git a/scripts/poetry.lock b/python/poetry.lock similarity index 100% rename from scripts/poetry.lock rename to python/poetry.lock diff --git a/scripts/pyproject.toml b/python/pyproject.toml similarity index 62% rename from scripts/pyproject.toml rename to python/pyproject.toml index db6745e..8f42824 100644 --- a/scripts/pyproject.toml +++ b/python/pyproject.toml @@ -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 "] license = "MIT" -readme = "README.md" +[tool.poetry.scripts] +convert_to_json = "scripts.convert_to_json:main" [tool.poetry.dependencies] python = ">=3.7" diff --git a/scripts/convert_to_json.py b/python/scripts/convert_to_json.py similarity index 86% rename from scripts/convert_to_json.py rename to python/scripts/convert_to_json.py index a2ac2f9..6573907 100644 --- a/scripts/convert_to_json.py +++ b/python/scripts/convert_to_json.py @@ -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")