|
5 | 5 | types: [opened, synchronize, reopened] |
6 | 6 |
|
7 | 7 | jobs: |
| 8 | + request-approval: |
| 9 | + name: Request Approval |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + pull-requests: write |
| 13 | + steps: |
| 14 | + - name: Comment requesting approval |
| 15 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 |
| 16 | + with: |
| 17 | + script: | |
| 18 | + // Check if approval comment already exists |
| 19 | + const { data: comments } = await github.rest.issues.listComments({ |
| 20 | + owner: context.repo.owner, |
| 21 | + repo: context.repo.repo, |
| 22 | + issue_number: context.issue.number, |
| 23 | + }); |
| 24 | +
|
| 25 | + const approvalComment = comments.find(comment => |
| 26 | + comment.body.includes('<!-- approval-request-comment -->') |
| 27 | + ); |
| 28 | +
|
| 29 | + // Only create comment if it doesn't exist |
| 30 | + if (!approvalComment) { |
| 31 | + await github.rest.issues.createComment({ |
| 32 | + owner: context.repo.owner, |
| 33 | + repo: context.repo.repo, |
| 34 | + issue_number: context.issue.number, |
| 35 | + body: `<!-- approval-request-comment --> |
| 36 | + ## ⚠️ Manual approval required |
| 37 | +
|
| 38 | + A repository owner must approve the Docker preview deployment for this PR. |
| 39 | +
|
| 40 | + **PR Author:** @${{ github.event.pull_request.user.login }} |
| 41 | + **Head SHA:** \`${{ github.event.pull_request.head.sha }}\` |
| 42 | +
|
| 43 | + [Review and approve in Actions →](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})` |
| 44 | + }); |
| 45 | + } |
| 46 | +
|
8 | 47 | pr-preview: |
9 | 48 | name: Deploy on Docker |
10 | 49 | runs-on: ubuntu-latest |
| 50 | + needs: request-approval |
| 51 | + environment: |
| 52 | + name: "PR Preview" |
| 53 | + url: https://github.com/${{ github.repository }}/pkgs/container/actions-clever-cloud |
11 | 54 | permissions: |
12 | 55 | contents: read |
13 | 56 | packages: write |
|
0 commit comments