GitHub Actions Workflow Generator#

The GitHub Actions generator creates YAML workflow files that orchestrate CI/CD processes using GitHub’s built-in action system. Workflows leverage the DevOps-OS container for a consistent build environment.


Basic Usage#

python -m cli.devopsos scaffold gha --name "my-app" --type complete

Output: .github/workflows/my-app-complete.yml

The filename pattern is <name-hyphenated>-<type>.yml inside the output directory.
Change the output directory with --output <dir> (default: .github/workflows/).


Options#

OptionDefaultDescription
--name NAMEDevOps-OSWorkflow name
--type TYPEcompletebuild | test | deploy | complete | reusable
--languages LANGSpython,javascriptComma-separated: python, java, javascript, go
--kubernetesoffInclude Kubernetes deployment steps
--registry URLghcr.ioContainer registry URL
--k8s-method METHODkubectlkubectl | kustomize | argocd | flux
--output DIR.github/workflowsOutput directory
--custom-values FILE(none)Path to custom values JSON file
--image IMAGEghcr.io/yourorg/devops-os:latestDevOps-OS container image
--branches BRANCHESmainComma-separated branches that trigger the workflow
--matrixoffEnable matrix builds across OS/architectures
--env-file FILE(cli dir)Path to devcontainer.env.json
--reusableoffGenerate a reusable workflow

Workflow Types#

TypeDescription
buildFocuses on building and packaging your application
testFocuses on running tests
deployFocuses on deploying to the target environment
completeCombines build, test, and deploy stages
reusableCreates a workflow callable from other workflows

Examples#

Python application — complete pipeline#

python -m cli.devopsos scaffold gha --name "Python App" --languages python --type complete
# Output: .github/workflows/python-app-complete.yml

Java with Maven#

python -m cli.devopsos scaffold gha --name "Java Service" --languages java --custom-values maven-config.json
# Output: .github/workflows/java-service-complete.yml

Multi-language microservices with Kubernetes#

python -m cli.devopsos scaffold gha \
  --name "Microservices" \
  --languages python,javascript,go \
  --kubernetes --k8s-method kustomize
# Output: .github/workflows/microservices-complete.yml

Matrix build (cross-platform)#

python -m cli.devopsos scaffold gha --name "Node.js App" --languages javascript --matrix
# Output: .github/workflows/node-js-app-complete.yml

Reusable workflow#

python -m cli.devopsos scaffold gha --name "shared" --type reusable
# Output: .github/workflows/shared-reusable.yml

Environment Variables#

All options can be set using environment variables prefixed with DEVOPS_OS_GHA_:

export DEVOPS_OS_GHA_NAME="API Service"
export DEVOPS_OS_GHA_TYPE="complete"
export DEVOPS_OS_GHA_LANGUAGES="python,go"
export DEVOPS_OS_GHA_KUBERNETES="true"
export DEVOPS_OS_GHA_K8S_METHOD="kustomize"
export DEVOPS_OS_GHA_MATRIX="true"

python -m cli.devopsos scaffold gha
# Output: .github/workflows/api-service-complete.yml

Kubernetes Deployment Methods#

MethodWhat happens
kubectlDirect deployment using kubectl set image and rollout status
kustomizekustomize edit set image + kubectl apply -k
argocdargocd app set + sync + wait
fluxflux reconcile + kustomization reconcile

Reusable Workflows#

Call the generated reusable workflow from another workflow:

jobs:
  call-devops-os-workflow:
    uses: ./.github/workflows/shared-reusable.yml
    with:
      languages: '{"python": true, "java": true}'
      deploy_environment: 'production'

Custom Values File#

{
  "build": {
    "cache": true,
    "timeout_minutes": 30,
    "artifact_paths": ["dist/**", "build/**"]
  },
  "test": {
    "coverage": true,
    "junit_reports": true,
    "parallel": 4
  },
  "deploy": {
    "environments": ["dev", "staging", "prod"],
    "approval_required": true,
    "rollback_enabled": true
  },
  "matrix": {
    "os": ["ubuntu-latest", "windows-latest", "macos-latest"],
    "architecture": ["x86_64", "arm64"]
  }
}
python -m cli.devopsos scaffold gha --custom-values advanced-config.json

Generated Workflow Structure#

name: My CI/CD
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/yourorg/devops-os:latest
    steps:
      - uses: actions/checkout@v3
      # Language-specific build steps...

  test:
    needs: build
    # ...

  deploy:
    needs: test
    if: github.event_name == 'push'
    # ...

Best Practices#

  1. Start with --type complete and remove stages you don’t need
  2. Pin the --image to a specific tag in production
  3. Use --env-file to align CI/CD with your local dev container
  4. Use reusable workflows to standardize pipelines across multiple repos
  5. Store secrets in GitHub Secrets, reference them with ${{ secrets.MY_SECRET }}