From 7d4da66665c45ed4719753e0d8d52e71e6ff3c69 Mon Sep 17 00:00:00 2001 From: Ace Data Cloud Dev Date: Fri, 27 Mar 2026 20:01:54 +0800 Subject: [PATCH] feat: add auto-sync from Docs pipeline and Claude Code Action --- .github/workflows/auto-merge.yml | 55 ++++++++++ .github/workflows/claude.yml | 36 +++++++ .github/workflows/sync-from-docs.yml | 153 +++++++++++++++++++++++++++ CLAUDE.md | 41 +++++++ 4 files changed, 285 insertions(+) create mode 100644 .github/workflows/auto-merge.yml create mode 100644 .github/workflows/claude.yml create mode 100644 .github/workflows/sync-from-docs.yml create mode 100644 CLAUDE.md diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 0000000..fb410dd --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,55 @@ +name: Auto-merge bot PRs + +on: + pull_request: + types: [opened, synchronize] + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + if: | + github.event.pull_request.user.login == 'AceDataCloudDev' || + github.event.pull_request.user.login == 'github-actions[bot]' || + contains(github.event.pull_request.title, '[auto-sync]') + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Wait for CI checks + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + pr_number=${{ github.event.pull_request.number }} + echo "Waiting for CI checks on PR #$pr_number..." + max_attempts=30 + for i in $(seq 1 $max_attempts); do + sleep 30 + status=$(gh pr checks "$pr_number" --json name,state --jq '[.[] | select(.name != "auto-merge")] | if length == 0 then "pass" elif all(.state == "SUCCESS" or .state == "SKIPPED") then "pass" elif any(.state == "FAILURE") then "fail" else "pending" end' 2>/dev/null || echo "pending") + echo "Attempt $i/$max_attempts: status=$status" + if [ "$status" = "pass" ]; then + echo "All checks passed!" + break + elif [ "$status" = "fail" ]; then + echo "CI checks failed. Skipping auto-merge." + exit 0 + fi + done + + - name: Approve PR + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + gh pr review ${{ github.event.pull_request.number }} --approve + + - name: Enable auto-merge + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + gh pr merge ${{ github.event.pull_request.number }} \ + --auto --squash \ + --subject "sync: auto-merge from Docs update [automated]" diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 0000000..0623043 --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,36 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + issues: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: Run Claude Code + uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + github_token: ${{ secrets.BOT_GITHUB_TOKEN }} + env: + ANTHROPIC_BASE_URL: https://api.acedata.cloud + ANTHROPIC_DEFAULT_SONNET_MODEL: claude-sonnet-4-20250514 diff --git a/.github/workflows/sync-from-docs.yml b/.github/workflows/sync-from-docs.yml new file mode 100644 index 0000000..fb35be0 --- /dev/null +++ b/.github/workflows/sync-from-docs.yml @@ -0,0 +1,153 @@ +name: Sync from Docs + +on: + repository_dispatch: + types: [docs-updated] + workflow_dispatch: + inputs: + force: + description: "Force sync even without detected changes" + required: false + default: "false" + type: boolean + +permissions: + contents: write + pull-requests: write + issues: write + id-token: write + +jobs: + create-sync-issue: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout this repo + uses: actions/checkout@v4 + + - name: Checkout Docs repo + uses: actions/checkout@v4 + with: + repository: AceDataCloud/Docs + path: _docs + token: ${{ secrets.BOT_GITHUB_TOKEN }} + + - name: Gather Docs changes + id: changes + run: | + cd _docs + diff_info=$(git log -1 --pretty=format:"%h %s" 2>/dev/null || echo "unknown") + echo "commit_info=$diff_info" >> "$GITHUB_OUTPUT" + + echo "## Current Docs Content for Suno" > /tmp/docs_context.md + echo "" >> /tmp/docs_context.md + + # Collect all Suno guide docs in English + if [ -d en/guides/suno ]; then + echo "### English Integration Guides" >> /tmp/docs_context.md + for f in en/guides/suno/*.mdx; do + if [ -f "$f" ]; then + echo "" >> /tmp/docs_context.md + echo "#### $(basename "$f")" >> /tmp/docs_context.md + head -100 "$f" >> /tmp/docs_context.md + fi + done + elif [ -d guides/suno ]; then + echo "### Integration Guides (zh-CN)" >> /tmp/docs_context.md + for f in guides/suno/*.mdx; do + if [ -f "$f" ]; then + echo "" >> /tmp/docs_context.md + echo "#### $(basename "$f")" >> /tmp/docs_context.md + head -100 "$f" >> /tmp/docs_context.md + fi + done + fi + + echo "" >> /tmp/docs_context.md + + # OpenAPI spec summary + if [ -f openapi/suno.json ]; then + echo "### OpenAPI Endpoints" >> /tmp/docs_context.md + echo '```' >> /tmp/docs_context.md + python3 -c " + import json + with open('openapi/suno.json') as f: + spec = json.load(f) + for path, methods in spec.get('paths', {}).items(): + for method, op in methods.items(): + print(f'{method.upper()} {path}: {op.get(\"summary\", \"\")}') + " 2>/dev/null || echo "(parse error)" + echo '```' >> /tmp/docs_context.md + fi + + cd .. + docs_context=$(cat /tmp/docs_context.md) + if [ ${#docs_context} -gt 8000 ]; then + docs_context="${docs_context:0:8000}...(truncated)" + fi + echo "$docs_context" > /tmp/docs_context_final.md + + - name: Check for existing open sync issue + id: existing + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + existing=$(gh issue list --label "auto-sync" --state open --json number --jq '.[0].number // empty') + if [ -n "$existing" ]; then + echo "exists=true" >> "$GITHUB_OUTPUT" + echo "issue_number=$existing" >> "$GITHUB_OUTPUT" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create sync issue + if: steps.existing.outputs.exists != 'true' + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + docs_context=$(cat /tmp/docs_context_final.md) + commit_info="${{ steps.changes.outputs.commit_info }}" + + body=$(cat <<'ISSUE_BODY' + @claude + + The upstream **Docs** repository has been updated. Please review the changes and update this API documentation repo. + + ## About This Repo + + This repo contains API integration guides in `docs/` and a `README.md` with the service intro page. Content should match the upstream Docs. + + ## What to Check + + 1. **docs/*.md files** — Compare existing guides against the Docs integration guides below. Add new guides for new endpoints, update existing ones with new parameters/models. + 2. **README.md** — Update the model version table, feature list, and examples if new capabilities were added. + 3. **Model versions** — Ensure all available model versions mentioned in the OpenAPI spec are documented. + + ## Instructions + + - Only make changes if the Docs content shows new information not yet in this repo. + - If no changes are needed, close this issue with a comment explaining why. + - If changes are needed, create a PR with the updates. + - Keep the writing style consistent with existing docs. + ISSUE_BODY + ) + + full_body=$(printf '%s\n\n## Docs Content\n\n%s' "$body" "$docs_context") + + gh issue create \ + --title "sync: update from Docs ($commit_info)" \ + --label "auto-sync" \ + --body "$full_body" + + - name: Update existing issue + if: steps.existing.outputs.exists == 'true' + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + docs_context=$(cat /tmp/docs_context_final.md) + commit_info="${{ steps.changes.outputs.commit_info }}" + + body=$(printf '@claude\n\nNew Docs update detected (%s). Please re-check and update if needed.\n\n%s' "$commit_info" "$docs_context") + + gh issue comment "${{ steps.existing.outputs.issue_number }}" \ + --body "$body" diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..103654f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,41 @@ +# SunoAPI + +API documentation and integration guides for Suno AI music generation on AceDataCloud. + +## Project Structure + +``` +README.md — Service intro page with features, pricing, and examples +docs/ — Per-endpoint integration guides (markdown) + suno_audios_generation_api_integration_guide.md + suno_lyrics_generation_api_integration_guide.md + suno_mashup_lyrics_generation_api_integration_guide.md + suno_midi_api_integration_guide.md + suno_mp4_api_integration_guide.md + suno_persona_api_integration_guide.md + suno_style_api_integration_guide.md + suno_tasks_api_integration_guide.md + suno_timing_api_integration_guide.md + suno_upload_api_integration_guide.md + suno_vox_api_integration_guide.md + suno_wav_api_integration_guide.md +``` + +## Sync from Docs + +When working on an auto-sync issue (labeled `auto-sync`), follow these rules: + +1. **Compare guides** — Each API endpoint should have a corresponding guide in `docs/`. Add new guides for new endpoints, matching the naming pattern. +2. **Model versions** — Update model version tables in guides and README to match the latest from Docs. +3. **Parameters** — Update parameter documentation to match the OpenAPI spec. +4. **Examples** — Update code examples (curl, Python, JavaScript) with latest models and parameters. +5. **README** — Update feature list, model table, and pricing info. +6. **PR title** — Use format: `sync: [auto-sync]` + +## Writing Style + +- English documentation +- Include curl examples for every endpoint +- Include model version table with launch dates and limits +- Include parameter reference tables +- Use consistent heading structure: Overview → Application → Basic Usage → Advanced → Response