Skip to content

Commit 5e7809f

Browse files
authored
fix: docs sync auto-merges via devops bot (CopilotKit#3804)
## Summary - Uses `copilotkit-devops-bot` token (via `actions/create-github-app-token`) to create PR, push branch, and merge - Bot is a bypass actor on `PROTECT_OUR_MAIN` ruleset — can merge without review approval - `gh pr merge --merge` (immediate) instead of `--auto` — no manual intervention needed - Fully automated: docs change on main → sync → PR → merge → Slack notification ## What changed - Added `actions/create-github-app-token@v1` step to generate bot token - Git remote URL overridden with bot token for push - PR created and merged by bot in a single step - Slack says "auto-merged" not "needs approval" ## Test plan - [ ] Retrigger docs sync, verify PR is created AND merged automatically - [ ] Verify Slack notification says "auto-merged" 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 2433fe2 + 7a5ebbf commit 5e7809f

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

.github/workflows/showcase_docs-sync.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,24 @@ jobs:
6464
exit 1
6565
fi
6666
67-
# Create PR for clean transforms (branch protection blocks direct push to main)
68-
- name: Create PR for clean transforms
67+
# Generate a token from copilotkit-devops-bot (bypass actor on branch protection)
68+
- name: Generate bot token
69+
id: bot-token
70+
if: steps.sync.outputs.action == 'auto_push' || steps.sync.outputs.action == 'push_and_pr'
71+
uses: actions/create-github-app-token@v1
72+
with:
73+
app-id: 1108748
74+
private-key: ${{ secrets.DEVOPS_BOT_PRIVATE_KEY }}
75+
76+
# Create PR and auto-merge via devops bot (bypasses branch protection)
77+
- name: Create and merge PR for clean transforms
6978
id: push
7079
if: steps.sync.outputs.action == 'auto_push' || steps.sync.outputs.action == 'push_and_pr'
7180
env:
72-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
GH_TOKEN: ${{ steps.bot-token.outputs.token }}
7382
run: |
74-
git config user.name "github-actions[bot]"
75-
git config user.email "github-actions[bot]@users.noreply.github.com"
83+
git config user.name "copilotkit-devops-bot[bot]"
84+
git config user.email "copilotkit-devops-bot[bot]@users.noreply.github.com"
7685
7786
SHORT_SHA=$(git rev-parse --short origin/main)
7887
BRANCH="docs-sync/auto/${SHORT_SHA}-$(date +%s)"
@@ -88,29 +97,31 @@ jobs:
8897
fi
8998
9099
git commit --no-verify -m "chore: auto-sync docs from main ($(date +%Y-%m-%d))"
100+
101+
# Override git credential to use bot token (checkout configured GITHUB_TOKEN)
102+
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
91103
git push origin "$BRANCH"
92104
93105
PR_URL=$(gh pr create \
94106
--title "chore: auto-sync docs from main (${SHORT_SHA})" \
95-
--body "Automated docs sync. Clean transforms only — safe to merge." \
107+
--body "Automated docs sync. Clean transforms only." \
96108
--base "$SHOWCASE_BRANCH" \
97109
--head "$BRANCH")
98110
99111
echo "Created PR: $PR_URL"
112+
gh pr merge "$PR_URL" --merge
100113
101114
echo "files_changed=${CHANGED}" >> "$GITHUB_OUTPUT"
102115
echo "pr_url=${PR_URL}" >> "$GITHUB_OUTPUT"
103116
104-
# Branch protection requires 1 approval — GITHUB_TOKEN can't self-approve,
105-
# so the PR needs manual merge. Notify Slack with the PR link.
106117
- name: Notify Slack (auto-sync)
107118
if: always() && steps.push.outcome == 'success' && steps.push.outputs.files_changed != '0'
108119
uses: slackapi/slack-github-action@v2.1.0
109120
with:
110121
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
111122
webhook-type: incoming-webhook
112123
payload: |
113-
{ "text": ":arrows_counterclockwise: *Docs sync*: PR ready for ${{ steps.push.outputs.files_changed || '?' }} file(s) — needs approval + merge\n${{ steps.push.outputs.pr_url || '' }}\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>" }
124+
{ "text": ":arrows_counterclockwise: *Docs sync*: auto-merged ${{ steps.push.outputs.files_changed || '?' }} file(s)\n${{ steps.push.outputs.pr_url || '' }}\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>" }
114125
115126
# Review items = files the sync script flagged but did NOT write to disk
116127
# (local modifications, files deleted on main). No file changes to propose —

0 commit comments

Comments
 (0)