Skip to content
This repository was archived by the owner on Jun 25, 2026. It is now read-only.

fix(codex): report per-run token usage from session events #193

fix(codex): report per-run token usage from session events

fix(codex): report per-run token usage from session events #193

Workflow file for this run

name: Deploy Rascal
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: deploy-rascal-main
cancel-in-progress: true
jobs:
verify:
name: Verify
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
should_deploy: ${{ steps.gate.outputs.should_deploy }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect non-doc changes
if: github.event_name != 'workflow_dispatch'
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
non_docs:
- '**'
- '!docs/**'
- '!**/*.md'
- name: Set deploy gate
id: gate
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] || [ "${{ steps.changes.outputs.non_docs }}" = "true" ]; then
echo "should_deploy=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "should_deploy=false" >> "$GITHUB_OUTPUT"
- name: Skip docs-only change
if: github.event_name != 'workflow_dispatch' && steps.changes.outputs.non_docs != 'true'
run: echo "Docs-only main update; skipping verify and deploy."
- name: Setup Go
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.non_docs == 'true'
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run linter
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.non_docs == 'true'
run: make lint
- name: Run tests
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.non_docs == 'true'
run: make test
- name: Verify generated files are committed
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.non_docs == 'true'
run: git diff --exit-code
deploy:
name: Deploy to server
needs: verify
if: needs.verify.outputs.should_deploy == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
env:
DEPLOY_HOST: ${{ vars.RASCAL_DEPLOY_HOST || secrets.RASCAL_DEPLOY_HOST }}
DEPLOY_USER: ${{ vars.RASCAL_DEPLOY_SSH_USER || secrets.RASCAL_DEPLOY_SSH_USER || 'root' }}
DEPLOY_PORT: ${{ vars.RASCAL_DEPLOY_SSH_PORT || secrets.RASCAL_DEPLOY_SSH_PORT || '22' }}
DEPLOY_RUNNER_IMAGE_GOOSE_CODEX: ${{ vars.RASCAL_RUNNER_IMAGE_GOOSE_CODEX || vars.RASCAL_RUNNER_IMAGE_GOOSE || 'rascal-runner-goose-codex:latest' }}
DEPLOY_RUNNER_IMAGE_CODEX: ${{ vars.RASCAL_RUNNER_IMAGE_CODEX || 'rascal-runner-codex:latest' }}
DEPLOY_RUNNER_IMAGE_CLAUDE: ${{ vars.RASCAL_RUNNER_IMAGE_CLAUDE || 'rascal-runner-claude:latest' }}
DEPLOY_RUNNER_IMAGE_GOOSE_CLAUDE: ${{ vars.RASCAL_RUNNER_IMAGE_GOOSE_CLAUDE || 'rascal-runner-goose-claude:latest' }}
DEPLOY_DOMAIN: ${{ vars.RASCAL_DOMAIN || secrets.RASCAL_DOMAIN || '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Validate deploy config
run: |
if [ -z "${DEPLOY_HOST:-}" ]; then
echo "Missing DEPLOY_HOST. Set vars/secrets RASCAL_DEPLOY_HOST." >&2
exit 1
fi
if [ -z "${{ secrets.RASCAL_DEPLOY_SSH_KEY }}" ]; then
echo "Missing secret RASCAL_DEPLOY_SSH_KEY." >&2
exit 1
fi
if [ -z "${{ secrets.RASCAL_DEPLOY_KNOWN_HOSTS }}" ]; then
echo "Missing secret RASCAL_DEPLOY_KNOWN_HOSTS." >&2
exit 1
fi
- name: Configure SSH
run: |
mkdir -p "$HOME/.ssh"
printf '%s\n' "${{ secrets.RASCAL_DEPLOY_SSH_KEY }}" > "$HOME/.ssh/id_ed25519"
printf '%s\n' "${{ secrets.RASCAL_DEPLOY_KNOWN_HOSTS }}" > "$HOME/.ssh/known_hosts"
chmod 600 "$HOME/.ssh/id_ed25519"
chmod 644 "$HOME/.ssh/known_hosts"
- name: Mask deploy endpoints
run: |
if [ -n "${DEPLOY_HOST:-}" ]; then
echo "::add-mask::${DEPLOY_HOST}"
fi
if [ -n "${DEPLOY_DOMAIN:-}" ]; then
echo "::add-mask::${DEPLOY_DOMAIN}"
echo "::add-mask::https://${DEPLOY_DOMAIN}"
echo "::add-mask::http://${DEPLOY_DOMAIN}"
fi
- name: Deploy
env:
RASCAL_BUILD_COMMIT: ${{ github.sha }}
run: |
export RASCAL_BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
go build -o ./bin/rascal ./cmd/rascal
./bin/rascal deploy \
--host "${DEPLOY_HOST}" \
--ssh-user "${DEPLOY_USER}" \
--ssh-port "${DEPLOY_PORT}" \
--ssh-key "$HOME/.ssh/id_ed25519" \
--domain "${DEPLOY_DOMAIN}" \
--runner-image-goose-codex "${DEPLOY_RUNNER_IMAGE_GOOSE_CODEX}" \
--runner-image-codex "${DEPLOY_RUNNER_IMAGE_CODEX}" \
--runner-image-claude "${DEPLOY_RUNNER_IMAGE_CLAUDE}" \
--runner-image-goose-claude "${DEPLOY_RUNNER_IMAGE_GOOSE_CLAUDE}"