diff --git a/.github/workflows/check-multi-package-addition-removal.sh b/.github/workflows/check-multi-package-addition-removal.sh index f1f44fde27d..0dc7157652e 100755 --- a/.github/workflows/check-multi-package-addition-removal.sh +++ b/.github/workflows/check-multi-package-addition-removal.sh @@ -1,15 +1,15 @@ #!/bin/bash set -o pipefail -# Initialize the variable -echo "MULTI_PACKAGE_ADD_REMOVE_DETECTED=false" >> $GITHUB_ENV - # Setup RPM tools source "$(git rev-parse --show-toplevel)"/toolkit/scripts/rpmops.sh # Define directories to watch SPEC_DIRS=("SPECS" "SPECS-EXTENDED") +# Initialize the variable to false +multi_package_add_remove_detected=false + # Fetch the latest state of the base branch git fetch origin $GITHUB_BASE_REF @@ -32,7 +32,7 @@ check_multi_package_add_remove() { for package in "${!package_counts[@]}"; do if [ "${package_counts[$package]}" -gt 1 ]; then echo "Multi-package add/remove of .spec file detected: $package in $DIR" - echo "MULTI_PACKAGE_ADD_REMOVE_DETECTED=true" >> $GITHUB_ENV + multi_package_add_remove_detected=true fi done } @@ -47,4 +47,7 @@ for spec_dir in "${SPEC_DIRS[@]}"; do # Check for duplicates in the directory check_multi_package_add_remove "$dir_path" done -done \ No newline at end of file +done + +# Print true or false based on detection of duplicates +echo $multi_package_add_remove_detected diff --git a/.github/workflows/check-multi-package.yml b/.github/workflows/check-multi-package.yml index a97d4d46b28..b6a084b6d84 100644 --- a/.github/workflows/check-multi-package.yml +++ b/.github/workflows/check-multi-package.yml @@ -1,40 +1,50 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -name: Check Multi-package +trigger: none -on: - pull_request: - branches: - - karimeldegwy/* - paths: - - 'SPECS/**' - - 'SPECS-EXTENDED/**' +pr: + branches: + include: + - 1.0-dev + - main + - 3.0-dev + - karimeldegwy/** -permissions: 'write-all' + paths: + include: + - SPECS/** + - SPECS-EXTENDED/** + +variables: + - group: "Agent pools (DEV)" + +resources: + repositories: + - repository: CBL-Mariner-Pipelines + type: git + name: mariner/CBL-Mariner-Pipelines jobs: - detect-changes: - runs-on: ubuntu-latest + - job: 'MultiPackageCheck' + pool: + name: "$(DEV_AMD64_Ubuntu_Managed)" + type: linux + isCustom: true + timeoutInMinutes: 15 + displayName: 'Add reviewer if multi-package addition/removal detected' steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Ensures history for all branches is available - - - name: Check Multi-package addition/removal - run: | - .github/workflows/check-multi-package-addition-removal.sh + - script: | + echo "Checking for multi-package addition/removal" + result=$(./.github/workflows/check-multi-package-addition-removal.sh) + echo "##vso[task.setvariable variable=MULTI_PACKAGE_ADD_REMOVE_DETECTED;isOutput=true]$result" + displayName: 'Check Multi-package Addition/Removal' env: - GITHUB_BASE_REF: ${{ github.base_ref }} - GITHUB_WORKSPACE: ${{ github.workspace }} + GITHUB_BASE_REF: $(System.PullRequest.TargetBranch) + GITHUB_WORKSPACE: $(Build.SourcesDirectory) + name: checkMultiPackage - - name: Add Reviewer if Duplicates Found - if: env.MULTI_PACKAGE_ADD_REMOVE_DETECTED == 'true' - run: | - curl \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/microsoft/azurelinux/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ - -d '{"team_reviewers": ["cbl-mariner-multi-package-reviewers"]}' \ No newline at end of file + - template: pipelines/multi-package/AddMultiPackTeamAsReviewer.yml@CBL-Mariner-Pipelines + condition: and(succeeded(), eq(dependencies.MultiPackageCheck.outputs['checkMultiPackage.MULTI_PACKAGE_ADD_REMOVE_DETECTED'], 'true')) + parameters: + prID: $(System.PullRequest.PullRequestId)