|
13 | 13 | paths-ignore: |
14 | 14 | - '.github/**' |
15 | 15 | jobs: |
| 16 | + check_approvals: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + # Run this job only if the following conditions are met: |
| 19 | + # 1. The pull request has the 'integration-test' label. |
| 20 | + # 2. The event is either: |
| 21 | + # a. A 'pull_request' event where the base and head repositories are the same (internal PR). |
| 22 | + # b. A 'pull_request_target' event where the base and head repositories are different (external PR). |
| 23 | + if: ${{ contains(github.event.pull_request.labels.*.name, 'integration-test') && |
| 24 | + (( github.event_name == 'pull_request' && github.event.pull_request.base.repo.clone_url == github.event.pull_request.head.repo.clone_url) || |
| 25 | + (github.event_name == 'pull_request_target' && github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url )) }} |
| 26 | + outputs: |
| 27 | + # Output the approval status for pull_request_target events, otherwise default to 'true' |
| 28 | + check_approvals: ${{ github.event_name == 'pull_request_target' && steps.check_approvals.outputs.check_approvals || 'true' }} |
| 29 | + # Output whether the PR is external |
| 30 | + external_pr: ${{ github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url }} |
| 31 | + steps: |
| 32 | + - name: Check integration test allowance status |
| 33 | + # Only run this step for pull_request_target events |
| 34 | + if: ${{ github.event_name == 'pull_request_target' }} |
| 35 | + id: check_approvals |
| 36 | + # Use an external action to check if the PR has the necessary approvals |
| 37 | + uses: nutanix-cloud-native/action-check-approvals@v1 |
| 38 | + |
16 | 39 | build-container: |
| 40 | + if: ${{ (github.event_name == 'pull_request' && needs.check_approvals.outputs.external_pr == 'false') || (github.event_name == 'pull_request_target' && needs.check_approvals.outputs.external_pr == 'true' && needs.check_approvals.outputs.check_approvals == 'true') }} |
| 41 | + needs: check_approvals |
17 | 42 | runs-on: ubuntu-latest |
18 | 43 | steps: |
19 | 44 | - name: Checkout |
|
83 | 108 | - "capx-feature-test" |
84 | 109 | - "scaling" |
85 | 110 | fail-fast: false |
| 111 | + if: ${{ (github.event_name == 'pull_request' && needs.check_approvals.outputs.external_pr == 'false') || (github.event_name == 'pull_request_target' && needs.check_approvals.outputs.external_pr == 'true' && needs.check_approvals.outputs.check_approvals == 'true') }} |
| 112 | + needs: check_approvals |
86 | 113 | uses: ./.github/workflows/e2e.yaml |
87 | 114 | with: |
88 | 115 | e2e-labels: ${{ matrix.e2e-labels }} |
|
0 commit comments