You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add official GitHub Action for CI/CD integration (#2683)
* feat: Add official GitHub Action for datamodel-code-generator with usage examples and inputs documentation
* feat: Refactor GitHub Action script to streamline argument handling and improve readability
* feat: Add 'extras' input to GitHub Action for optional dependency installation with usage examples
* feat: Simplify argument handling in GitHub Action by using an array for datamodel-codegen command
Copy file name to clipboardExpand all lines: docs/ci-cd.md
+160-1Lines changed: 160 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,165 @@ This guide covers how to use datamodel-code-generator in CI/CD pipelines and dev
9
9
10
10
---
11
11
12
+
## Official GitHub Action
13
+
14
+
The official GitHub Action provides a simple way to validate generated models in your CI pipeline.
15
+
16
+
### Basic Usage
17
+
18
+
```yaml
19
+
- uses: koxudaxi/datamodel-code-generator@0.44.0
20
+
with:
21
+
input: schema.yaml
22
+
output: src/models.py
23
+
input-file-type: openapi
24
+
output-model-type: pydantic_v2.BaseModel
25
+
```
26
+
27
+
By default, the action runs in **check mode** (`--check`), which validates that the existing output file matches what would be generated. If they differ, the action fails.
Always pin the action to a specific version tag (e.g., `@0.44.0`) to ensure reproducible builds. The action installs the same version of `datamodel-code-generator` as the tag.
168
+
169
+
---
170
+
12
171
## The `--check` Flag
13
172
14
173
The `--check` flag verifies that generated code matches existing files without modifying them. If the output would differ, it exits with a non-zero status code.
0 commit comments