Example: GitHub Actions
This workflow tracks an AI code review job with the Keito CLI. It starts a timer, runs the review script, and then either stops or discards the timer during cleanup.
Prerequisites
KEITO_API_KEYstored as a GitHub secret.KEITO_ACCOUNT_IDstored as a GitHub secret. Find it in Keito under Settings > API & Developers > Company ID.KEITO_PROJECT_IDset as a GitHub variable.KEITO_TASK_IDset as a GitHub variable.- An AI review script at
./scripts/ai-review.sh.
Full Code
name: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
env:
KEITO_API_KEY: ${{ secrets.KEITO_API_KEY }}
KEITO_ACCOUNT_ID: ${{ secrets.KEITO_ACCOUNT_ID }}
KEITO_PROJECT_ID: ${{ vars.KEITO_PROJECT_ID }}
KEITO_TASK_ID: ${{ vars.KEITO_TASK_ID }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Install Keito CLI
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -LsSf \
https://github.com/osodevops/keito-cli/releases/latest/download/keito-installer.sh | sh
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Run AI review with Keito tracking
shell: bash
run: |
set -euo pipefail
export PATH="$HOME/.cargo/bin:$PATH"
STARTED=0
cleanup() {
status=$?
if [ "$STARTED" = "1" ]; then
if [ "$status" -eq 0 ]; then
keito time stop \
--notes "AI code review for PR #${{ github.event.pull_request.number }}" \
--json || true
else
keito time stop --discard --json || true
fi
fi
}
trap cleanup EXIT
keito auth status --json
keito time start \
--project "$KEITO_PROJECT_ID" \
--task "$KEITO_TASK_ID" \
--notes "AI code review for PR #${{ github.event.pull_request.number }}" \
--json
STARTED=1
./scripts/ai-review.sh
How It Works
- Installs the latest Keito CLI release.
- Verifies credentials with
keito auth status --json. - Starts a timer using project and task IDs from repository variables.
- Runs your AI review script.
- Stops the timer on success or discards it on failure.
The current CLI tracks time only. Log token costs through the Keito web app, Expenses API, Node SDK, or Python SDK.