Skip to content

Commit

Permalink
[#24] PR 자동 생성 GitHub Actions를 추가한다
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoungqu23 committed Dec 30, 2024
1 parent 309684b commit 295f3e6
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/create-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Auto Create or Update PR

on:
push:
branches:
[
feature/*,
release/*,
bugfix/*,
hotfix/*,
refactor/*,
test/*,
docs/*,
chore/*,
]

jobs:
auto_pr:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Create or Update PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 현재 브랜치 이름 가져오기
CURRENT_BRANCH=$(echo $GITHUB_REF | sed 's|refs/heads/||')
echo "Current branch: $CURRENT_BRANCH"
# 기존 PR이 있는지 확인
EXISTING_PR=$(gh pr list --head "$CURRENT_BRANCH" --json number -q ".[0].number")
if [ -z "$EXISTING_PR" ]; then
echo "No existing PR. Creating a new one..."
gh pr create \
--title "Auto PR for $CURRENT_BRANCH" \
--body "This PR was automatically created for the branch $CURRENT_BRANCH." \
--base main
else
echo "PR #$EXISTING_PR exists. Syncing with the latest changes..."
gh pr comment "$EXISTING_PR" --body "Branch updated with new changes."
fi

0 comments on commit 295f3e6

Please sign in to comment.