Skip to content

Commit c898551

Browse files
authored
Merge pull request #107 from asperpharma/copilot/fix-all-issues
feat(ci): auto-create PR from fix/feature branches
2 parents 18912b2 + 3eabb2d commit c898551

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Auto-create PR from fixed/feature branches
2+
# Repo: asperpharma/understand-project
3+
#
4+
# On every push to a fix/**, feature/**, copilot/**, or claude/** branch,
5+
# automatically opens a pull request against main if one does not already exist.
6+
#
7+
# Uses the built-in GITHUB_TOKEN — no extra secrets required.
8+
#
9+
name: Auto-create PR from feature/fix branch
10+
11+
on:
12+
push:
13+
branches:
14+
- 'fix/**'
15+
- 'feature/**'
16+
- 'copilot/**'
17+
- 'claude/**'
18+
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
23+
jobs:
24+
create-pr:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Open pull request if none exists
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: |
34+
BRANCH="${{ github.ref_name }}"
35+
36+
# Check whether a PR already targets main from this branch
37+
EXISTING=$(gh pr list --head "$BRANCH" --base main --json number --jq '.[0].number' 2>/dev/null || true)
38+
if [ -n "$EXISTING" ]; then
39+
echo "PR #$EXISTING already exists for branch '$BRANCH'. Nothing to do."
40+
exit 0
41+
fi
42+
43+
# Derive a human-readable title from the branch name
44+
TITLE=$(echo "$BRANCH" | sed 's|.*/||' | tr '-_' ' ' | awk '{for(i=1;i<=NF;i++){sub(/./,toupper(substr($i,1,1)),$i)}; print}')
45+
46+
gh pr create \
47+
--title "$TITLE" \
48+
--body "Automated pull request for branch \`$BRANCH\`." \
49+
--base main \
50+
--head "$BRANCH"
51+
52+
echo "Pull request created for branch '$BRANCH'."

0 commit comments

Comments
 (0)