Skip to content

Commit 7649134

Browse files
author
DevForge Engineer
committed
cowork-bot: seed server-side auto-PR workflow for cowork/improve-* branches
Enables the Cowork rotation to open a PR without sandbox GitHub API access (the workflow runs on push with the repo GITHUB_TOKEN and creates the PR if none exists).
1 parent 1e7ca76 commit 7649134

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Seeded by the repo-improver-rotation Cowork job into cowork/improve-* branches.
2+
# Opens a PR automatically when such a branch is pushed (sandbox cannot reach
3+
# the GitHub API directly; this runs server-side with the repo's GITHUB_TOKEN).
4+
name: cowork-auto-pr
5+
on:
6+
push:
7+
branches: ['cowork/improve-**']
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
jobs:
12+
ensure-pr:
13+
runs-on: ubuntu-latest
14+
steps:
15+
# gh pr create requires a local git checkout to diff head against base;
16+
# without this step every run failed with "not a git repository" and no
17+
# PR was ever opened (fleet-wide defect: 11/11 seeded copies lacked it).
18+
- name: Check out the pushed branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.ref_name }}
22+
fetch-depth: 0
23+
- name: Open PR for this branch if none exists
24+
env:
25+
GH_TOKEN: ${{ github.token }}
26+
run: |
27+
set -eu
28+
existing=$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$GITHUB_REF_NAME" --state open --json number --jq 'length')
29+
if [ "$existing" = "0" ]; then
30+
gh pr create --repo "$GITHUB_REPOSITORY" \
31+
--head "$GITHUB_REF_NAME" \
32+
--title "cowork-bot: automated improvements ($GITHUB_REF_NAME)" \
33+
--body "Automated improvement PR from the Cowork repo-improver rotation (one coherent senior-dev improvement per run; see individual commit messages). Subsequent runs push additional commits to this PR rather than opening new ones."
34+
else
35+
echo "Open PR already exists for $GITHUB_REF_NAME — nothing to do."
36+
fi

0 commit comments

Comments
 (0)