# The GitHub Action

Our [Action for GitHub workflows](https://github.com/jorgeortega/latitude10-action) scores your document in the workflow, can fail the job on a low score or a breaking change, and can push the version to the registry. It's public, under MIT.

### 1. Add the key

Add your project key to the repository's secrets as `LATITUDE10_KEY`. The Action scores and gates without it; pushing and fixes need it.

### 2. Add the step

```yaml
- uses: jorgeortega/latitude10-action@v1
  with:
    spec: openapi.yaml
    min-score: 70          # fail below this; default: report only
    max-tools: 40          # fail above this many operations; default 40
    fail-on-breaking: true # default false
    push: ${{ github.ref == 'refs/heads/main' }}
    suggest-fixes: true    # paid plans; opens or updates one PR
  env:
    LATITUDE10_KEY: ${{ secrets.LATITUDE10_KEY }}   # optional
```

## Inputs

| Input | What it does | Default |
| --- | --- | --- |
| `spec` | The path to your OpenAPI document, YAML or JSON. Local `$ref`s are bundled. Required. | None |
| `min-score` | Fail when the readiness score is below this, from 0 to 100. | Empty: report only |
| `max-tools` | Fail when the document has more operations than this, since each one becomes an agent tool. | `40` |
| `fail-on-breaking` | Fail when the document has breaking changes against its base. | `false` |
| `push` | With `LATITUDE10_KEY`, push this version to the registry. | `false` |
| `suggest-fixes` | With `LATITUDE10_KEY` on a paid plan, open or update one pull request with rules-only fixes. | `false` |
| `label` | The version's label in the registry. | Empty: `info.version` |
| `github-token` | The token for the fixes pull request. It needs contents and pull-requests write. | The workflow's token |
| `api-url` | The Latitude 10 API. | `https://latitude10.tech` |

## Outputs

| Output | What it holds |
| --- | --- |
| `score` | The readiness score, from 0 to 100. |
| `operations` | The number of operations. |
| `breaking` | The breaking changes against the base. |
| `version-url` | With `push`, the version's page in the registry. |

The Action has no input for docs yet. Push a docs folder with `curl` from a step of its own.

## Without the Action

One `curl` step pushes the document on every merge to `main`:

```yaml
- name: Push the spec to Latitude 10
  if: github.ref == 'refs/heads/main'
  run: >
    curl --fail-with-body -X POST
    "https://latitude10.tech/api/registry/v1/versions?git_sha=$GITHUB_SHA&git_ref=$GITHUB_REF"
    -H "Authorization: Bearer $LATITUDE10_KEY"
    --data-binary @openapi.yaml
  env:
    LATITUDE10_KEY: ${{ secrets.LATITUDE10_KEY }}
```

[Push a version](push) lists what it answers.

## Where this comes from

- `app/registry/_lib/ci.ts`
- `app/api/registry/v1/versions/route.ts`
- `app/registry/_lib/versions.ts`
- `app/registry/_lib/bundle.ts`
- `app/registry/_lib/usage.ts`
