Skip to content

feat: sync SDK with API changes #6

feat: sync SDK with API changes

feat: sync SDK with API changes #6

Workflow file for this run

name: API Sync Fix
on:
pull_request:
types: [opened, synchronize]
branches: [main]
permissions:
contents: write
pull-requests: write
id-token: write
checks: read
actions: read
jobs:
fix:
name: Fix CI failures on api-sync PR
if: github.head_ref == 'api-sync'
runs-on: ubuntu-latest
steps:
- name: Wait for CI to complete
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Waiting for CI checks to complete..."
for i in $(seq 1 30); do
STATUS=$(gh pr checks ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json name,state --jq '[.[] | select(.name != "Fix CI failures on api-sync PR")] | if all(.state == "SUCCESS") then "pass" elif any(.state == "FAILURE") then "fail" elif all(.state == "SUCCESS" or .state == "FAILURE" or .state == "SKIPPED") then "done" else "pending" end')
echo "Check status: $STATUS (attempt $i/30)"
if [ "$STATUS" = "pass" ]; then
echo "All checks passed!"
echo "ci_failed=false" >> $GITHUB_ENV
exit 0
elif [ "$STATUS" = "fail" ]; then
echo "CI failed, will attempt fix"
echo "ci_failed=true" >> $GITHUB_ENV
exit 0
fi
sleep 20
done
echo "Timed out waiting for checks"
echo "ci_failed=false" >> $GITHUB_ENV
- uses: actions/checkout@v4
if: env.ci_failed == 'true'
with:
ref: api-sync
token: ${{ secrets.SDK_SYNC_PAT }}
- name: Get CI error logs
if: env.ci_failed == 'true'
id: errors
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FAILED_RUNS=$(gh pr checks ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json name,state,link --jq '.[] | select(.state == "FAILURE") | .name')
echo "Failed checks: $FAILED_RUNS"
# Get error logs from failed workflow runs
ERRORS=""
for run_url in $(gh pr checks ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json name,state,link --jq '.[] | select(.state == "FAILURE") | .link'); do
RUN_ID=$(echo "$run_url" | grep -oP 'runs/\K\d+')
if [ -n "$RUN_ID" ]; then
JOB_ERRORS=$(gh run view "$RUN_ID" --log-failed 2>/dev/null | tail -30)
ERRORS="$ERRORS\n--- $RUN_ID ---\n$JOB_ERRORS"
fi
done
echo "$ERRORS" > /tmp/ci-errors.txt
echo "Saved CI errors to /tmp/ci-errors.txt"
- name: Fix errors with Claude Code
if: env.ci_failed == 'true'
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
claude_args: '--allowedTools "Bash(*),Read,Edit,Write,Glob,Grep"'
additional_permissions: |
actions: read
checks: read
prompt: |
CI checks failed on this PR. Read CLAUDE.md for codebase standards, then fix the errors.
The CI error logs are at /tmp/ci-errors.txt
Instructions:
1. Read /tmp/ci-errors.txt to understand what failed (lint, type checking, or tests).
2. Read CLAUDE.md for the project's conventions and commands.
3. Fix all errors in the code — do not skip or ignore any.
4. Run the same lint/type check/test commands locally to verify your fixes pass.
5. Do NOT create commits — just modify the files.
- name: Commit and push fixes
if: env.ci_failed == 'true'
run: |
git remote set-url origin "https://x-access-token:${{ secrets.SDK_SYNC_PAT }}@github.com/${{ github.repository }}.git"
git checkout -- .github/workflows/ 2>/dev/null || true
git add -A
git reset HEAD .github/workflows/ 2>/dev/null || true
if git diff --staged --quiet; then
echo "No fixes needed"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "fix: resolve CI errors from api-sync"
git push origin api-sync