Skip to content

Add check_approvals action to build-dev workflow #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,29 @@ on:
paths-ignore:
- '.github/**'
jobs:
check_approvals:
# Run this job only if the following conditions are met:
# 1. The pull request has the 'integration-test' label.
# 2. The event is either:
# a. A 'pull_request' event where the base and head repositories are the same (internal PR).
# b. A 'pull_request_target' event where the base and head repositories are different (external PR).
if: ${{ contains(github.event.pull_request.labels.*.name, 'integration-test') && ( github.event_name == 'pull_request' && github.event.pull_request.base.repo.clone_url == github.event.pull_request.head.repo.clone_url || github.event_name == 'pull_request_target' && github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url ) }}
runs-on: self-hosted-nutanix-medium
outputs:
# Output the approval status for pull_request_target events, otherwise default to 'true'
check_approvals: ${{ github.event_name == 'pull_request_target' && steps.check_approvals.outputs.check_approvals || 'true' }}
# Output whether the PR is external
external_pr: ${{ github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url }}
steps:
- name: Check integration test allowance status
# Only run this step for pull_request_target events
if: ${{ github.event_name == 'pull_request_target' }}
id: check_approvals
# Use an external action to check if the PR has the necessary approvals
uses: nutanix-cloud-native/action-check-approvals@v1

build-container:
needs: check_approvals
runs-on: ubuntu-latest
env:
EXPORT_RESULT: true
Expand Down Expand Up @@ -75,6 +97,7 @@ jobs:
e2e-labels:
- "capx"
fail-fast: false
needs: check_approvals
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also needs a check

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') }}

uses: ./.github/workflows/e2e.yaml
with:
e2e-labels: ${{ matrix.e2e-labels }}
Expand Down
Loading