Companion to StructKit. Run validate, generate, or a dry-run drift check as a workflow step. Star the core repo.
- π Validate structure definitions on every PR
- π Generate project structures in CI/CD workflows
- π Drift Detection - detect when generated files don't match definitions
- π‘οΈ Safe Defaults - runs with
--no-hooksand--non-interactiveby default - π¦ Custom Structures - supports external structure repositories
- π― Flexible Versioning - install from PyPI, git, or specific versions
name: Validate Structure
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: validateCheck if generated files match their definitions (fail if they don't):
name: Check Structure Drift
on: [pull_request]
jobs:
drift-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: generate
dry_run: true
diff: true
fail_on_diff: trueGenerate structure without creating a PR (useful for pre-commit hooks or local automation):
name: Generate Structure
on:
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: generate
struct_file: .struct.yaml
output_dir: .
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: regenerate structure" || echo "No changes to commit"
git push| Input | Description | Required | Default |
|---|---|---|---|
command |
Command to run: validate or generate |
No | validate |
struct_file |
Path to the StructKit configuration file | No | .struct.yaml |
output_dir |
Output directory for generated files | No | . |
dry_run |
Run in dry-run mode (preview changes without writing) | No | false |
diff |
Show diff of changes (use with dry_run for drift detection) | No | false |
no_hooks |
Disable hooks during execution (check if your StructKit version supports this flag) | No | false |
non_interactive |
Run in non-interactive mode (check if your StructKit version supports this flag) | No | false |
structkit_version |
StructKit version to install (version number, latest, or git URL) |
No | latest |
structures_path |
Path to custom structures directory | No | '' |
structures_repository |
Custom structures repository to checkout (format: owner/repo) |
No | '' |
structures_repository_path |
Path within structures_repository where structures are located | No | structures |
structures_repository_ref |
Git ref (branch/tag/commit) to checkout from structures_repository | No | main |
extra_args |
Additional arguments to pass to StructKit command | No | '' |
python_version |
Python version to use | No | 3.x |
fail_on_diff |
Fail the action if changes would be made (drift detection) | No | false |
| Output | Description |
|---|---|
success |
Whether the command completed successfully (true/false) |
has_changes |
Whether the command would make changes (dry-run) or made changes (true/false) |
diff_file |
Path to the diff output file (if generated) |
exit_code |
Exit code from the StructKit command |
This repository uses automated release management with semantic versioning:
- Release Drafting: Releases are automatically drafted when PRs are merged to main
- First Release: Will be tagged as
v1.0.0 - Major Version Tags: When a release like
v1.2.3is published, the major tagv1is automatically created/moved to point to it - Pinning Recommendations:
- Use
@v1to automatically get minor and patch updates (recommended for most users) - Use
@v1.0.0to pin to a specific version
- Use
The major version tag (v1) is maintained automatically, so users can always reference the latest stable v1.x.x release using @v1.
- uses: httpdss/structkit-action@v1
with:
command: validate
structkit_version: "1.2.3"- uses: httpdss/structkit-action@v1
with:
command: generate
structkit_version: "https://github.com/httpdss/structkit.git@main"- uses: httpdss/structkit-action@v1
with:
command: generate
structures_repository: myorg/my-structures
structures_repository_path: templates
structures_repository_ref: v2.0- uses: httpdss/structkit-action@v1
with:
command: generate
extra_args: "--verbose --force"- uses: httpdss/structkit-action@v1
id: structkit
with:
command: generate
dry_run: true
diff: true
- name: Check for changes
if: steps.structkit.outputs.has_changes == 'true'
run: |
echo "Structure would be modified!"
cat ${{ steps.structkit.outputs.diff_file }}jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
struct_file:
- .struct.yaml
- config/api.struct.yaml
- config/frontend.struct.yaml
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: validate
struct_file: ${{ matrix.struct_file }}This action is designed to be a step in your workflow, not a complete workflow. Key differences:
| Feature | This Action | Reusable Workflow |
|---|---|---|
| Type | Composite action (step) | Complete workflow (job) |
| PR Creation | No (you control it) | Yes (built-in) |
| Flexibility | High (mix with other steps) | Lower (standalone job) |
| Use Case | Custom workflows | Quick automation |
If you need automatic PR creation, use the reusable workflow. If you need fine-grained control over your pipeline, use this action.
- Python 3.x (automatically installed by the action)
- GitHub Actions runner with bash support
This action is designed to work with different versions of StructKit. Some command-line flags (--no-hooks, --non-interactive, --diff, --dry-run) may not be available in all versions. The action defaults to not using these flags unless explicitly enabled. Check your StructKit version's documentation to confirm which flags are supported.
- Setup - Installs Python and StructKit
- Checkout - Optionally checks out custom structures repository
- Execute - Runs the specified StructKit command
- Outputs - Provides execution results for downstream steps
- Cleanup - Removes temporary files
name: Validate
on:
pull_request:
branches: [main]
jobs:
validate-structure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: validatename: Daily Drift Check
on:
schedule:
- cron: '0 0 * * *'
jobs:
drift-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: generate
dry_run: true
diff: true
fail_on_diff: truename: Generate Structure
on:
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v7
- uses: httpdss/structkit-action@v1
with:
command: generate
- uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore: regenerate structure"
title: "Update generated structure"
body: "Automated structure regeneration"
branch: "structkit/update-${{ github.run_id }}"If structkit command is not found, ensure Python is properly set up:
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: httpdss/structkit-action@v1When using structures_repository, ensure your workflow has access:
permissions:
contents: readThe action detects changes by parsing StructKit output. If the output format changes, the detection might not work. Check the action logs for the actual command output.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.
- StructKit - The main StructKit project
- StructKit Reusable Workflow - Full workflow with PR creation
For issues and questions: