|
9 | 9 | workflow_dispatch: |
10 | 10 |
|
11 | 11 | jobs: |
| 12 | + check-approval: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + approved: ${{ steps.check.outputs.approved }} |
| 16 | + steps: |
| 17 | + - id: check |
| 18 | + env: |
| 19 | + IS_PUSH_OR_DISPATCH: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) }} |
| 20 | + AUTHOR_TRUSTED: ${{ contains(fromJSON('["MEMBER","OWNER","COLLABORATOR","CONTRIBUTOR"]'), github.event.pull_request.author_association) }} |
| 21 | + HAS_APPROVAL_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'preview-approved') }} |
| 22 | + run: | |
| 23 | + if [ "$IS_PUSH_OR_DISPATCH" = "true" ] || [ "$AUTHOR_TRUSTED" = "true" ] || [ "$HAS_APPROVAL_LABEL" = "true" ]; then |
| 24 | + echo "approved=true" >> "$GITHUB_OUTPUT" |
| 25 | + else |
| 26 | + echo "approved=false" >> "$GITHUB_OUTPUT" |
| 27 | + fi |
| 28 | +
|
12 | 29 | deploy: |
13 | | - if: github.event_name == 'push' || (github.event.action != 'closed' && github.event.action != 'labeled') |
| 30 | + needs: [check-approval] |
| 31 | + if: | |
| 32 | + github.event_name == 'push' || github.event_name == 'workflow_dispatch' || ( |
| 33 | + github.event.action != 'closed' && |
| 34 | + (github.event.action != 'labeled' || github.event.label.name == 'preview-approved') |
| 35 | + ) |
14 | 36 | uses: ./.github/workflows/ovh.yaml |
15 | 37 | with: |
16 | 38 | environment_name: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && 'production' || format('pull/{0}', github.event.pull_request.number) }} |
17 | 39 | url: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && format('https://{0}', vars.MAIN_WEBSITE) || format('https://{0}/pr/{1}', vars.PREVIEW_WEBSITE, github.event.pull_request.number) }} |
18 | 40 | target: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && 'www' || format('pulls/pr/{0}', github.event.pull_request.number) }} |
| 41 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 42 | + approval_required: ${{ needs.check-approval.outputs.approved == 'false' }} |
19 | 43 | action: deploy |
20 | 44 | secrets: inherit |
21 | 45 |
|
|
0 commit comments