Visitar URL original
structkit/docs/github-integration.md at main · httpdss/structkit · GitHub
Skip to content

Latest commit

 

History

History
103 lines (74 loc) · 3.41 KB

File metadata and controls

103 lines (74 loc) · 3.41 KB

GitHub Integration

StructKit can seamlessly integrate with GitHub to automate the generation of project structures across repositories.

Automating StructKit

Combine GitHub Actions with StructKit to automate project structure generation in CI/CD pipelines. Trigger the process manually or automatically based on events like pull requests or pushes.

Example Workflow:

name: run-struct

on:
  workflow_dispatch:

jobs:
  generate:
    uses: httpdss/structkit/.github/workflows/struct-generate.yaml@main
    secrets:
      token: ${{ secrets.STRUCT_RUN_TOKEN }}

When struct_file is omitted, the workflow uses .structkit.yaml if present and falls back to a legacy .struct.yaml.

Install StructKit in CI (httpdss/structkit-setup)

httpdss/structkit-setup installs StructKit onto PATH. Use it when you want to run arbitrary structkit commands in a job (list, validate, generate, or anything else the CLI supports):

- uses: actions/checkout@v7
- uses: httpdss/structkit-setup@v0
- run: structkit list
- run: structkit validate .structkit.yaml

Optional: pin the StructKit version on setup:

- uses: httpdss/structkit-setup@v0
  with:
    structkit-version: "3.3.0"

GitHub Action step (httpdss/structkit-action)

For validate, generate, or a dry-run diff/drift check as a step in your own job (instead of calling the reusable workflow as a complete job), use httpdss/structkit-action.

The actions are separate: structkit-action does not install StructKit or call setup internally. Use setup first, then the action:

- uses: actions/checkout@v7
- uses: httpdss/structkit-setup@v0
- uses: httpdss/structkit-action@v0
  with:
    command: validate
    struct_file: .structkit.yaml

Drift check (generate + --dry-run --diff):

- uses: actions/checkout@v7
- uses: httpdss/structkit-setup@v0
- uses: httpdss/structkit-action@v0
  with:
    command: generate
    struct_file: .structkit.yaml
    dry_run: true
    diff: true
    fail_on_diff: true

Generate:

- uses: actions/checkout@v7
- uses: httpdss/structkit-setup@v0
- uses: httpdss/structkit-action@v0
  with:
    command: generate
    struct_file: .structkit.yaml
    output_dir: .

The reusable workflow above is a full job with built-in PR creation. The action is a step you can mix with other checkout, test, or commit steps. See the setup README and the action README for full workflow examples and inputs.

Best Practices

  1. Secure Your Token: Store GitHub tokens in secrets management tools.
  2. Use Topics for Filtering: Organize repositories with topics to efficiently manage workflows.
  3. Test Locally First: Simulate script actions with --dry-run before executing in a CI/CD environment.
  4. Combine with Other Tools: Use StructKit with Terraform, Ansible, or Docker for comprehensive project management.

FAQs

Why use a GitHub Integration?

Using GitHub integration allows you to leverage StructKit's automation capabilities in a version-controlled environment, enabling consistent and repeatable project structures.

Can I customize the GitHub Action?

Yes, you can tailor the GitHub Action to your specific needs, including custom triggers, different environments, and additional dependencies.