Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
yml 126 lines 4.82 KB
Raw
1 name: Changelog → Docs PR
2
3 on:
4 push:
5 branches: [next]
6 paths:
7 - 'docs/content/changelog/**.mdx'
8
9 permissions:
10 contents: read
11
12 jobs:
13 suggest-docs-updates:
14 name: Suggest Documentation Updates
15 runs-on: ubuntu-latest
16 timeout-minutes: 30
17 permissions:
18 contents: write
19 pull-requests: write
20 id-token: write
21
22 steps:
23 # `GITHUB_TOKEN` cannot open pull requests here: the repository has
24 # "Allow GitHub Actions to create and approve pull requests" disabled, so
25 # `createPullRequest` is rejected no matter what `pull-requests` grants.
26 # Every other PR-opening workflow in this repo mints a release-bot App
27 # token for exactly this reason.
28 - name: Generate GitHub App token
29 id: app-token
30 uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
31 with:
32 client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
33 private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
34
35 - name: Checkout repository
36 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
37 with:
38 token: ${{ steps.app-token.outputs.token }}
39 fetch-depth: 0
40
41 - name: Detect new changelog files
42 id: detect
43 run: |
44 BEFORE="${{ github.event.before }}"
45 AFTER="${{ github.event.after }}"
46
47 if [[ "$BEFORE" =~ ^0+$ ]]; then
48 FILES=$(git diff --name-only --diff-filter=AM HEAD^..HEAD | grep '^docs/content/changelog/.*\.mdx$' || echo "")
49 else
50 FILES=$(git diff --name-only --diff-filter=AM "$BEFORE".."$AFTER" | grep '^docs/content/changelog/.*\.mdx$' || echo "")
51 fi
52
53 # Skip generated SDK release entries (frontmatter `sdkRelease:`); their release PR covers them.
54 FILES=$(printf '%s\n' "$FILES" | bash scripts/sdk-release/changelog-filter.sh)
55
56 if [ -z "$FILES" ]; then
57 echo "found=false" >> $GITHUB_OUTPUT
58 else
59 echo "found=true" >> $GITHUB_OUTPUT
60 echo "files<<EOF" >> $GITHUB_OUTPUT
61 echo "$FILES" >> $GITHUB_OUTPUT
62 echo "EOF" >> $GITHUB_OUTPUT
63 fi
64
65 - name: Codex updates docs
66 if: steps.detect.outputs.found == 'true'
67 uses: openai/codex-action@306c6a196a99dcc6582530c396a19d2672d5e9ec # v1.14
68 with:
69 openai-api-key: ${{ secrets.OPENAI_API_KEY }}
70 sandbox: workspace-write
71 prompt: |
72 New changelog entries were merged to next. Read the agent instructions and update documentation accordingly.
73
74 1. Read docs/agent-guidance/agents/changelog-docs-updater.md for full instructions
75 2. Read each of these changelog files:
76 ${{ steps.detect.outputs.files }}
77 3. For each change, search docs/content/docs/ for pages that need updating
78 4. Make the documentation updates following the agent instructions
79 5. If no docs changes are needed, make no file changes and explain why
80
81 - name: Create PR if docs changed
82 id: create-pr
83 if: steps.detect.outputs.found == 'true'
84 env:
85 GH_TOKEN: ${{ steps.app-token.outputs.token }}
86 run: |
87 if [ -z "$(git status --porcelain)" ]; then
88 echo "No documentation changes needed"
89 exit 0
90 fi
91
92 BRANCH="docs/changelog-update-${GITHUB_SHA::7}"
93 git config user.name "github-actions[bot]"
94 git config user.email "github-actions[bot]@users.noreply.github.com"
95 git checkout -b "$BRANCH"
96 git add -A
97 git commit -m "docs: update documentation for new changelog entries"
98 git push -u origin "$BRANCH"
99
100 # Requesting the reviewer is deliberately NOT part of this call: an
101 # unassignable actor (bot account, non-collaborator) would fail the
102 # whole command after the branch is already pushed, leaving an orphan
103 # branch and no PR. It runs as a separate best-effort step below.
104 PR_URL=$(gh pr create \
105 --base next \
106 --head "$BRANCH" \
107 --title "docs: update documentation for new changelog entries" \
108 --body "$(cat <<'EOF'
109 ## Summary
110 Automated documentation updates triggered by new changelog entries merged to next.
111
112 Generated by Codex via GitHub Actions.
113 EOF
114 )")
115
116 echo "$PR_URL"
117 echo "pull-request-number=$(basename "$PR_URL")" >> "$GITHUB_OUTPUT"
118
119 - name: Request review from pusher
120 if: steps.create-pr.outputs.pull-request-number
121 continue-on-error: true
122 env:
123 GH_TOKEN: ${{ steps.app-token.outputs.token }}
124 PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }}
125 AUTHOR: ${{ github.actor }}
126 run: gh pr edit "$PR_NUMBER" --add-reviewer "$AUTHOR"