|
| 1 | +name: Create Release PR |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-release-pr: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + - name: Generate GitHub App Token |
| 23 | + id: generate-token |
| 24 | + uses: tibdex/github-app-token@v1 |
| 25 | + with: |
| 26 | + app_id: ${{ secrets.APP_ID }} |
| 27 | + private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 28 | + installation_id: ${{ secrets.APP_INSTALLATION_ID }} |
| 29 | + |
| 30 | + - name: Create Release PR Branch |
| 31 | + run: | |
| 32 | + git config --global user.name "GitHub Actions" |
| 33 | + git config --global user.email "[email protected]" |
| 34 | +
|
| 35 | + # 현재 날짜와 시간을 포함한 고유한 브랜치 이름 생성 |
| 36 | + BRANCH_NAME="sync-main-to-release-$(date +'%Y%m%d-%H%M%S')" |
| 37 | + git checkout -b $BRANCH_NAME |
| 38 | +
|
| 39 | + # GitHub App 토큰을 사용하여 브랜치 푸시 |
| 40 | + git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }} |
| 41 | + git push origin $BRANCH_NAME |
| 42 | +
|
| 43 | + # 변경 내용 요약 |
| 44 | + COMMIT_MESSAGE=$(git log -1 --pretty=%B) |
| 45 | + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV |
| 46 | + echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV |
| 47 | +
|
| 48 | + - name: Create Pull Request |
| 49 | + uses: peter-evans/create-pull-request@v5 |
| 50 | + with: |
| 51 | + token: ${{ steps.generate-token.outputs.token }} |
| 52 | + base: release |
| 53 | + branch: ${{ env.BRANCH_NAME }} |
| 54 | + title: 'chore: sync main to release' |
| 55 | + body: | |
| 56 | + 이 PR은 메인 브랜치의 변경사항을 릴리즈 브랜치로 동기화합니다. |
| 57 | +
|
| 58 | + ## 주요 변경사항: |
| 59 | + ${{ env.COMMIT_MESSAGE }} |
| 60 | +
|
| 61 | + 이 PR이 머지되면 릴리즈 워크플로우가 자동으로 트리거됩니다. |
| 62 | + labels: | |
| 63 | + automated-pr |
| 64 | + sync-to-release |
0 commit comments