|
14 | 14 | - name: Checkout repo |
15 | 15 | uses: actions/checkout@v4 |
16 | 16 |
|
| 17 | + - name: Generate a token |
| 18 | + id: generate-token |
| 19 | + uses: actions/create-github-app-token@v2 |
| 20 | + with: |
| 21 | + app-id: ${{ vars.APP_ID_APPROVE_AND_MERGE }} |
| 22 | + private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }} |
| 23 | + owner: community-scripts |
| 24 | + repositories: ProxmoxVE-Local |
| 25 | + |
| 26 | + - name: Generate a token for PR approval and merge |
| 27 | + id: generate-token-merge |
| 28 | + uses: actions/create-github-app-token@v2 |
| 29 | + with: |
| 30 | + app-id: ${{ vars.APP_ID_APPROVE_AND_MERGE }} |
| 31 | + private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }} |
| 32 | + owner: community-scripts |
| 33 | + repositories: ProxmoxVE-Local |
| 34 | + |
17 | 35 |
|
18 | 36 | - name: Get latest draft release |
19 | 37 | id: draft |
@@ -67,17 +85,28 @@ jobs: |
67 | 85 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
68 | 86 |
|
69 | 87 |
|
70 | | - - name: Authenticate gh with PAT |
| 88 | + - name: Approve pull request |
| 89 | + if: env.changed == 'true' |
| 90 | + env: |
| 91 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
71 | 92 | run: | |
72 | | - echo "${{ secrets.PAT_MICHEL }}" | gh auth login --with-token |
73 | | -
|
| 93 | + PR_NUMBER="${{ steps.pr.outputs.pr_number }}" |
| 94 | + if [ -n "$PR_NUMBER" ]; then |
| 95 | + gh pr review $PR_NUMBER --approve |
| 96 | + fi |
74 | 97 |
|
75 | | - - name: Merge PR as PAT user |
76 | | - run: | |
77 | | - gh pr merge "${{ steps.pr.outputs.pr_number }}" --squash --body "Merge VERSION update" --admin |
| 98 | + - name: Approve pull request and merge |
| 99 | + if: env.changed == 'true' |
78 | 100 | env: |
79 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
80 | | - |
| 101 | + GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }} |
| 102 | + run: | |
| 103 | + git config --global user.name "github-actions-automege[bot]" |
| 104 | + git config --global user.email "github-actions-automege[bot]@users.noreply.github.com" |
| 105 | + PR_NUMBER="${{ steps.pr.outputs.pr_number }}" |
| 106 | + if [ -n "$PR_NUMBER" ]; then |
| 107 | + gh pr review "$PR_NUMBER" --approve |
| 108 | + gh pr merge "$PR_NUMBER" --squash --admin |
| 109 | + fi |
81 | 110 | |
82 | 111 | - name: Wait for PR merge |
83 | 112 | uses: actions/github-script@v7 |
|
0 commit comments