Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | name: Docs - Publish KB Guide |
| 2 | |
| 3 | # The support portal sends this when Front Desk proposes a KB change, and Zen (source: zen) sends it |
| 4 | # when a merged code PR changes what a guide says: a new guide, a rewrite or a retirement. It becomes |
| 5 | # one PR on next, and reviewing and merging that PR is the approval. Each guide |
| 6 | # lives in its own files (kb/guides/<slug>.json, kb/articles, kb/source) and content/kb is generated |
| 7 | # at build time, so PRs for different guides can wait for review side by side without conflicting. |
| 8 | on: |
| 9 | repository_dispatch: |
| 10 | types: [kb-guide-approved] |
| 11 | |
| 12 | permissions: |
| 13 | contents: read |
| 14 | |
| 15 | concurrency: |
| 16 | # Shared with docs-update-kb so each run starts from a settled next. |
| 17 | group: docs-kb-publication |
| 18 | cancel-in-progress: false |
| 19 | queue: max |
| 20 | |
| 21 | jobs: |
| 22 | publish: |
| 23 | runs-on: ubuntu-latest |
| 24 | permissions: |
| 25 | contents: read |
| 26 | defaults: |
| 27 | run: |
| 28 | shell: bash |
| 29 | working-directory: ./docs |
| 30 | |
| 31 | steps: |
| 32 | # Every payload field that reaches a branch name or the PR body is checked here first. |
| 33 | - name: Check request |
| 34 | id: request |
| 35 | env: |
| 36 | SOURCE: ${{ github.event.client_payload.source }} |
| 37 | DRAFT_ID: ${{ github.event.client_payload.draft_id }} |
| 38 | REQUEST_ID: ${{ github.event.client_payload.request_id }} |
| 39 | ORIGIN_URL: ${{ github.event.client_payload.origin_url }} |
| 40 | ORIGIN_AUTHOR: ${{ github.event.client_payload.origin_author }} |
| 41 | run: | |
| 42 | if [ "$SOURCE" = zen ]; then |
| 43 | if ! [[ "$REQUEST_ID" =~ ^[a-z0-9-]+$ ]]; then |
| 44 | echo "request_id must match ^[a-z0-9-]+$" >&2 |
| 45 | exit 1 |
| 46 | fi |
| 47 | if ! [[ "$ORIGIN_URL" =~ ^https://github\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/pull/[0-9]+$ ]]; then |
| 48 | echo "origin_url must be a GitHub pull request URL" >&2 |
| 49 | exit 1 |
| 50 | fi |
| 51 | if ! [[ "$ORIGIN_AUTHOR" =~ ^[A-Za-z0-9-]+$ ]]; then |
| 52 | echo "origin_author must be a GitHub login" >&2 |
| 53 | exit 1 |
| 54 | fi |
| 55 | echo "branch=docs/kb-$REQUEST_ID" >> "$GITHUB_OUTPUT" |
| 56 | elif [ -z "$SOURCE" ]; then |
| 57 | if ! [[ "$DRAFT_ID" =~ ^[0-9]+$ ]]; then |
| 58 | echo "draft_id must be a number" >&2 |
| 59 | exit 1 |
| 60 | fi |
| 61 | echo "branch=docs/kb-front-desk-$DRAFT_ID" >> "$GITHUB_OUTPUT" |
| 62 | else |
| 63 | echo "Unknown source: $SOURCE" >&2 |
| 64 | exit 1 |
| 65 | fi |
| 66 | working-directory: . |
| 67 | |
| 68 | - name: Checkout docs repository |
| 69 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 70 | with: |
| 71 | ref: next |
| 72 | persist-credentials: false |
| 73 | |
| 74 | - name: Setup Node.js, pnpm, Bun |
| 75 | uses: ./.github/actions/setup-node-pnpm-bun |
| 76 | |
| 77 | - name: Install dependencies |
| 78 | run: bun install --frozen-lockfile --ignore-scripts |
| 79 | |
| 80 | - name: Apply the approved guide |
| 81 | env: |
| 82 | GUIDE: ${{ toJSON(github.event.client_payload.guide) }} |
| 83 | run: | |
| 84 | printf '%s' "$GUIDE" > "$RUNNER_TEMP/kb-guide.json" |
| 85 | bun scripts/publish-kb-guide.ts "$RUNNER_TEMP/kb-guide.json" |
| 86 | |
| 87 | - name: Regenerate KB pages |
| 88 | env: |
| 89 | GUIDE_SLUG: ${{ github.event.client_payload.guide.slug }} |
| 90 | run: | |
| 91 | bun run generate:kb |
| 92 | bun run check:kb |
| 93 | # verify:kb exits 1 for any finding in the whole KB. Other guides' findings (such as |
| 94 | # expired review dates) are tracked by the data-sync freshness check; only this guide's |
| 95 | # errors and support prose, and KB-wide errors, block its publication. |
| 96 | bun run verify:kb --json > "$RUNNER_TEMP/kb-verify.json" || true |
| 97 | jq -e '.findings | type == "array"' "$RUNNER_TEMP/kb-verify.json" > /dev/null |
| 98 | if ! jq -e '[.findings[] | select(.kind == "unedited-support-prose" and .guideSlug == env.GUIDE_SLUG)] | length == 0' "$RUNNER_TEMP/kb-verify.json"; then |
| 99 | echo "KB publication contains support-facing prose. Rewrite it for public readers before approving again." >&2 |
| 100 | exit 1 |
| 101 | fi |
| 102 | if ! jq -e '[.findings[] | select(.severity == "error" and ((.guideSlug // "") == env.GUIDE_SLUG or (.guideSlug // "") == ""))] | length == 0' "$RUNNER_TEMP/kb-verify.json"; then |
| 103 | jq -r '.findings[] | select(.severity == "error" and ((.guideSlug // "") == env.GUIDE_SLUG or (.guideSlug // "") == "")) | "\(.kind): \(.detail)"' "$RUNNER_TEMP/kb-verify.json" >&2 |
| 104 | echo "KB publication fails verification. Fix the guide before approving again." >&2 |
| 105 | exit 1 |
| 106 | fi |
| 107 | |
| 108 | - name: Generate composio PR token |
| 109 | id: write-token |
| 110 | uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 |
| 111 | with: |
| 112 | client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }} |
| 113 | private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }} |
| 114 | owner: ComposioHQ |
| 115 | repositories: composio |
| 116 | permission-contents: write |
| 117 | permission-pull-requests: write |
| 118 | |
| 119 | - name: Create pull request |
| 120 | uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3 |
| 121 | with: |
| 122 | token: ${{ steps.write-token.outputs.token }} |
| 123 | commit-message: 'docs(kb): ${{ github.event.client_payload.summary }}' |
| 124 | title: 'docs(kb): ${{ github.event.client_payload.summary }}' |
| 125 | body: | |
| 126 | ${{ github.event.client_payload.source == 'zen' && format('KB guide change proposed by Zen from {0} (@{1}).', github.event.client_payload.origin_url, github.event.client_payload.origin_author) || 'KB guide change proposed by Front Desk in the support portal.' }} |
| 127 | |
| 128 | - Guide: `${{ github.event.client_payload.guide.slug }}` (${{ github.event.client_payload.guide.action }}) |
| 129 | ${{ github.event.client_payload.source != 'zen' && format('- Draft: {0}', github.event.client_payload.portal_url) || '' }} |
| 130 | |
| 131 | Review the article and merge to publish it; close the PR to dismiss it. Nothing merges on its own. |
| 132 | branch: ${{ steps.request.outputs.branch }} |
| 133 | base: next |
| 134 | add-paths: | |
| 135 | docs/kb/ |