Skip to content

Commit 9b2b744

Browse files
committed
test
1 parent 48e5d56 commit 9b2b744

1 file changed

Lines changed: 0 additions & 103 deletions

File tree

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +0,0 @@
1-
name: Sync PR to Documentation
2-
on:
3-
pull_request:
4-
types: [opened, reopened]
5-
branches:
6-
- main
7-
workflow_dispatch:
8-
inputs:
9-
pr_number:
10-
description: 'PR 번호'
11-
required: true
12-
branch:
13-
description: '원본 브랜치 이름'
14-
required: true
15-
title:
16-
description: 'PR 제목'
17-
required: true
18-
19-
jobs:
20-
sync-to-docs:
21-
runs-on: ubuntu-latest
22-
steps:
23-
- name: Checkout repository
24-
uses: actions/checkout@v4
25-
26-
- name: Set PR variables
27-
run: |
28-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
29-
echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> $GITHUB_ENV
30-
echo "PR_TITLE=${{ github.event.inputs.title }}" >> $GITHUB_ENV
31-
echo "PR_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
32-
else
33-
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
34-
echo "PR_TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV
35-
echo "PR_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
36-
fi
37-
38-
- name: Create branch and PR
39-
env:
40-
TARGET_REPO: "${{ secrets.TARGET_REPOSITORY }}"
41-
PAT_TOKEN: "${{ secrets.TARGET_REPO_TOKEN }}"
42-
TARGET_BRANCH: "main"
43-
GITHUB_REPO: "${{ github.repository }}"
44-
run: |
45-
# 리포지토리 이름 추출
46-
REPO_NAME=$(echo "$GITHUB_REPO" | cut -d'/' -f2)
47-
48-
# Git 설정
49-
git config --global user.name "GitHub Actions Bot"
50-
git config --global user.email "actions@github.com"
51-
52-
# 타임스탬프 생성
53-
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
54-
55-
# 브랜치 이름 설정
56-
BRANCH_CONTENT="${REPO_NAME}-pr${PR_NUMBER}"
57-
BRANCH_CONTENT=$(echo $BRANCH_CONTENT | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g')
58-
BRANCH_NAME="${TIMESTAMP}/${BRANCH_CONTENT}"
59-
60-
echo "생성될 브랜치 이름: ${BRANCH_NAME}"
61-
62-
# 대상 리포지토리 클론
63-
git clone "https://${PAT_TOKEN}@github.com/${TARGET_REPO}.git" target-repo
64-
cd target-repo
65-
66-
# 브랜치 생성
67-
git checkout -b "${BRANCH_NAME}" "${TARGET_BRANCH}"
68-
69-
# 빈 커밋 생성
70-
git commit --allow-empty -m "Auto-sync from ${REPO_NAME} PR #${PR_NUMBER}"
71-
git push origin "${BRANCH_NAME}"
72-
73-
# jq 설치
74-
sudo apt-get update && sudo apt-get install -y jq
75-
76-
# PR 본문 파일 생성
77-
echo "# 자동으로 생성된 PR입니다." > pr_body.txt
78-
echo "" >> pr_body.txt
79-
echo "## 원본 PR 정보" >> pr_body.txt
80-
echo "- **PR 번호:** #${PR_NUMBER}" >> pr_body.txt
81-
echo "- **PR 제목:** ${PR_TITLE}" >> pr_body.txt
82-
echo "- **원본 브랜치:** ${PR_BRANCH}" >> pr_body.txt
83-
echo "- **원본 저장소:** ${GITHUB_REPO}" >> pr_body.txt
84-
echo "- **링크:** https://github.com/${GITHUB_REPO}/pull/${PR_NUMBER}" >> pr_body.txt
85-
echo "- **생성 시간:** $(date)" >> pr_body.txt
86-
echo "" >> pr_body.txt
87-
echo "---" >> pr_body.txt
88-
echo "이 PR은 ${REPO_NAME} 저장소의 PR #${PR_NUMBER}에 대응하여 자동으로 생성되었습니다." >> pr_body.txt
89-
90-
# PR 본문 이스케이프
91-
PR_BODY_ESCAPED=$(jq -Rs . < pr_body.txt)
92-
93-
# PR 생성
94-
curl -X POST \
95-
-H "Authorization: token ${PAT_TOKEN}" \
96-
-H "Accept: application/vnd.github.v3+json" \
97-
"https://api.github.com/repos/${TARGET_REPO}/pulls" \
98-
-d "{
99-
\"title\": \"[Auto] ${REPO_NAME}: ${PR_TITLE}\",
100-
\"body\": ${PR_BODY_ESCAPED},
101-
\"head\": \"${BRANCH_NAME}\",
102-
\"base\": \"${TARGET_BRANCH}\"
103-
}"

0 commit comments

Comments
 (0)