|
8 | 8 | jobs: |
9 | 9 | sync-release: |
10 | 10 | runs-on: ubuntu-latest |
| 11 | + |
11 | 12 | steps: |
12 | 13 | - name: Checkout |
13 | 14 | uses: actions/checkout@v3 |
14 | 15 | with: |
15 | 16 | fetch-depth: 0 |
16 | 17 |
|
17 | | - - name: Update release branch |
| 18 | + - name: Generate GitHub App Token |
| 19 | + id: generate-token |
| 20 | + uses: tibdex/github-app-token@v1 |
| 21 | + with: |
| 22 | + app_id: ${{ secrets.APP_ID }} |
| 23 | + private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 24 | + installation_id: ${{ secrets.APP_INSTALLATION_ID }} |
| 25 | + |
| 26 | + - name: Sync release branch with main |
18 | 27 | env: |
19 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
20 | 29 | run: | |
21 | | - git config --global user.name "GitHub Actions" |
22 | | - git config --global user.email "[email protected]" |
| 30 | + git config --global user.name "GitHub App" |
| 31 | + git config --global user.email "[email protected]" |
| 32 | +
|
| 33 | + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git |
23 | 34 |
|
24 | | - # release 브랜치가 존재하는지 확인 |
25 | | - if git ls-remote --exit-code --heads origin release; then |
26 | | - # 존재하면 업데이트 |
27 | | - git fetch origin release |
| 35 | + git fetch origin |
| 36 | +
|
| 37 | + if git show-ref --quiet refs/remotes/origin/release; then |
28 | 38 | git checkout release |
29 | 39 | git merge --no-edit origin/main |
30 | 40 | else |
31 | | - # 존재하지 않으면 생성 |
32 | | - git checkout -b release |
| 41 | + git checkout -b release origin/main |
33 | 42 | fi |
34 | 43 |
|
35 | | - git push origin release |
| 44 | + if git diff --quiet origin/release; then |
| 45 | + echo "No changes to push." |
| 46 | + else |
| 47 | + git push origin release |
| 48 | + fi |
0 commit comments