Skip to content

Commit f20bc14

Browse files
authored
Add check_approvals (#536)
1 parent 5c9da3f commit f20bc14

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/build-dev.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,32 @@ on:
1313
paths-ignore:
1414
- '.github/**'
1515
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+
1639
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
1742
runs-on: ubuntu-latest
1843
steps:
1944
- name: Checkout
@@ -83,6 +108,8 @@ jobs:
83108
- "capx-feature-test"
84109
- "scaling"
85110
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
86113
uses: ./.github/workflows/e2e.yaml
87114
with:
88115
e2e-labels: ${{ matrix.e2e-labels }}

0 commit comments

Comments
 (0)