> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kymaapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Actions

> Use Kyma API in GitHub Actions for AI-powered code review and automation.

## PR Review Bot

Automatically review pull requests with AI when they're opened or updated.

### Setup

1. Add `KYMA_API_KEY` as a repository secret (Settings > Secrets > Actions)
2. Create `.github/workflows/ai-review.yml`:

```yaml theme={null}
name: AI Code Review
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get diff
        run: git diff origin/${{ github.base_ref }}...HEAD > diff.txt

      - name: AI Review
        env:
          KYMA_API_KEY: ${{ secrets.KYMA_API_KEY }}
        run: |
          REVIEW=$(curl -s https://kymaapi.com/v1/chat/completions \
            -H "Authorization: Bearer $KYMA_API_KEY" \
            -H "Content-Type: application/json" \
            -d "{
              \"model\": \"deepseek-v3\",
              \"messages\": [{
                \"role\": \"system\",
                \"content\": \"You are a senior code reviewer. Be concise. Focus on bugs, security issues, and improvements.\"
              }, {
                \"role\": \"user\",
                \"content\": \"Review this diff:\\n$(cat diff.txt | head -c 8000)\"
              }]
            }" | jq -r '.choices[0].message.content')

          gh pr comment ${{ github.event.pull_request.number }} \
            --body "## AI Code Review\n\n$REVIEW\n\n---\n*Powered by [Kyma API](https://kymaapi.com) — deepseek-v3*"
        env:
          GH_TOKEN: ${{ github.token }}
          KYMA_API_KEY: ${{ secrets.KYMA_API_KEY }}
```

## Changelog Generator

Generate release notes from commits:

```yaml theme={null}
name: Generate Changelog
on:
  release:
    types: [created]

jobs:
  changelog:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Generate changelog
        env:
          KYMA_API_KEY: ${{ secrets.KYMA_API_KEY }}
        run: |
          COMMITS=$(git log --oneline $(git describe --tags --abbrev=0 HEAD^)..HEAD)
          CHANGELOG=$(curl -s https://kymaapi.com/v1/chat/completions \
            -H "Authorization: Bearer $KYMA_API_KEY" \
            -H "Content-Type: application/json" \
            -d "{
              \"model\": \"qwen-3.6-plus\",
              \"messages\": [{
                \"role\": \"user\",
                \"content\": \"Write concise release notes from these commits:\\n$COMMITS\"
              }]
            }" | jq -r '.choices[0].message.content')
          echo "$CHANGELOG"
```

## Recommended Models

| Use Case     | Model           | Why                                   |
| ------------ | --------------- | ------------------------------------- |
| Code review  | `deepseek-v3`   | Best value, strong code understanding |
| Changelog    | `qwen-3.6-plus` | Best overall quality                  |
| Quick checks | `qwen-3-32b`    | Fastest response                      |

<Tip>
  Keep diffs under 8,000 characters to stay within model context limits. For large PRs, review file-by-file.
</Tip>
