# AutoGovern deployment gate: a GitHub Actions composite action.
#
# Copy this file and autogovern-gate.sh into one folder of your repository,
# for example .github/actions/autogovern-gate/, then add a step before your
# deploy step:
#
#   - uses: ./.github/actions/autogovern-gate
#     with:
#       system-id: ws_abc123
#       api-key: ${{ secrets.AUTOGOVERN_API_KEY }}
#
# The step fails, and stops the job, unless AutoGovern says the system may be
# deployed. See README.md (download: https://autogovern.io/download/ci/readme).
name: AutoGovern deployment gate
description: Fails the job unless AutoGovern says this AI system may be deployed.
inputs:
  system-id:
    description: The system's ID (ws_...), from Workbench -> AI Registry.
    required: true
  api-key:
    description: A Governance API key with the gate:read scope. Pass it from a secret.
    required: true
  api-url:
    description: The AutoGovern address.
    required: false
    default: https://autogovern.io
  model-card:
    description: Path to the model card. Empty looks for MODEL_CARD.md and similar names.
    required: false
    default: ''
runs:
  using: composite
  steps:
    - name: Check the AutoGovern deployment gate
      shell: bash
      env:
        AUTOGOVERN_API_KEY: ${{ inputs.api-key }}
        AUTOGOVERN_SYSTEM_ID: ${{ inputs.system-id }}
        AUTOGOVERN_URL: ${{ inputs.api-url }}
        AUTOGOVERN_MODEL_CARD: ${{ inputs.model-card }}
      run: sh "$GITHUB_ACTION_PATH/autogovern-gate.sh"
