Skip to content

Commit 0203133

Browse files
authored
Merge pull request #3 from isayanpal/feat/auto-pr
ci: add auto PR workflow for development -> master
2 parents 284be7d + 2dc38d3 commit 0203133

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/auto-pr.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Auto PR development → master
2+
3+
on:
4+
push:
5+
branches:
6+
- development
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
auto-pr:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Create or update PR
22+
id: create-pr
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
# Collect commits on development not yet in master
27+
COMMITS=$(git log origin/master..HEAD --pretty=format:"- %s (%h)" | head -20)
28+
29+
BODY="## Changes
30+
31+
${COMMITS}
32+
33+
---
34+
Automated PR: \`development\` → \`master\`"
35+
36+
# Check if PR already exists
37+
EXISTING_PR=$(gh pr list \
38+
--base master \
39+
--head development \
40+
--state open \
41+
--json number \
42+
--jq '.[0].number')
43+
44+
if [ -n "$EXISTING_PR" ]; then
45+
gh pr edit "$EXISTING_PR" --body "$BODY"
46+
echo "Updated PR #$EXISTING_PR"
47+
echo "pr_number=$EXISTING_PR" >> $GITHUB_OUTPUT
48+
else
49+
PR_URL=$(gh pr create \
50+
--base master \
51+
--head development \
52+
--title "chore: merge development into master" \
53+
--body "$BODY")
54+
55+
PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]*$')
56+
echo "Created PR #$PR_NUMBER"
57+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
58+
fi
59+

0 commit comments

Comments
 (0)