diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83191bd1df4..788a09cffac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,9 +24,6 @@ jobs: ready-to-merge-gate: name: Ready-to-merge gate uses: ./.github/workflows/ready-to-merge-workflow.yml - with: - is-pr: ${{ github.event_name == 'pull_request' }} - labels: ${{ toJson(github.event.pull_request.labels) }} files-changed: name: Detect File Changes diff --git a/.github/workflows/ready-to-merge-workflow.yml b/.github/workflows/ready-to-merge-workflow.yml index 402593eb85f..8d5227c82ce 100644 --- a/.github/workflows/ready-to-merge-workflow.yml +++ b/.github/workflows/ready-to-merge-workflow.yml @@ -1,15 +1,6 @@ name: Ready to Merge Workflow on: workflow_call: - inputs: - labels: - description: The GitHub event's labels - required: true - type: string - is-pr: - description: Whether the workflow is running on a PR - required: true - type: boolean jobs: ready-to-merge-gate: @@ -17,25 +8,37 @@ jobs: runs-on: ubuntu-latest steps: - name: Check for exact 'ready-to-merge' label - if: ${{ inputs.is-pr }} + if: ${{ github.event_name == 'pull_request' }} id: check-label - run: | - # Use jq to check for exact label match (avoids substring matching issues with contains()) - if echo '${{ inputs.labels }}' | jq -e '.[] | select(.name == "ready-to-merge")' > /dev/null; then - echo "label_found=true" >> $GITHUB_OUTPUT - else - echo "label_found=false" >> $GITHUB_OUTPUT - fi + uses: actions/github-script@v7 + with: + script: | + const expectedLabel = 'ready-to-merge'; + + // Fetch labels from GitHub API + // GitHub Actions may not contain the labels in the event, so we need to fetch them from the API. + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + + const labelNames = labels.map(label => label.name); + console.log(`Found labels: ${labelNames.join(', ')}`); + + // Check for exact 'ready-to-merge' label match + const labelFound = labelNames.includes(expectedLabel); + core.setOutput('label_found', labelFound.toString()); # Since Github also accepts `skipped` results for Required Workflows, we need # to fail the job to ensure that the downstream jobs don't just skip. - name: Fail until the 'ready-to-merge' label is present - if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'false' }} + if: ${{ github.event_name == 'pull_request' && steps.check-label.outputs.label_found == 'false' }} run: | echo "Add the 'ready-to-merge' label to run CI." exit 1 - name: Gate passed - if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'true' }} + if: ${{ github.event_name == 'pull_request' && steps.check-label.outputs.label_found == 'true' }} run: echo "Label present. Proceeding with CI." - name: Gate passed - if: ${{ !inputs.is-pr }} + if: ${{ github.event_name != 'pull_request' }} run: echo "Not a PR. Proceeding with CI." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0cee5875a6a..a49971f5048 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,9 +37,6 @@ jobs: ready-to-merge-gate: name: Ready-to-merge gate uses: ./.github/workflows/ready-to-merge-workflow.yml - with: - is-pr: ${{ github.event_name == 'pull_request' }} - labels: ${{ toJson(github.event.pull_request.labels) }} files-changed: name: Detect File Changes diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4bd63eea9d..caf83832e93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,9 +24,6 @@ jobs: ready-to-merge-gate: name: Ready-to-merge gate uses: ./.github/workflows/ready-to-merge-workflow.yml - with: - is-pr: ${{ github.event_name == 'pull_request' }} - labels: ${{ toJson(github.event.pull_request.labels) }} # This job detects if the PR contains changes that require running unit tests. # If yes, the job will output a flag that will be used by the next job to run the unit tests. diff --git a/.github/workflows/ui-tests-critical.yml b/.github/workflows/ui-tests-critical.yml index 4a55157f271..e5ec4357b25 100644 --- a/.github/workflows/ui-tests-critical.yml +++ b/.github/workflows/ui-tests-critical.yml @@ -23,9 +23,6 @@ jobs: ready-to-merge-gate: name: Ready-to-merge gate uses: ./.github/workflows/ready-to-merge-workflow.yml - with: - is-pr: ${{ github.event_name == 'pull_request' }} - labels: ${{ toJson(github.event.pull_request.labels) }} files-changed: name: Detect File Changes diff --git a/.github/workflows/ui-tests.yml b/.github/workflows/ui-tests.yml index e2fdced3c29..db2bc424ee6 100644 --- a/.github/workflows/ui-tests.yml +++ b/.github/workflows/ui-tests.yml @@ -23,9 +23,6 @@ jobs: ready-to-merge-gate: name: Ready-to-merge gate uses: ./.github/workflows/ready-to-merge-workflow.yml - with: - is-pr: ${{ github.event_name == 'pull_request' }} - labels: ${{ toJson(github.event.pull_request.labels) }} files-changed: name: Detect File Changes diff --git a/develop-docs/CI.md b/develop-docs/CI.md index 09ee96b7c8e..7e89b81163c 100644 --- a/develop-docs/CI.md +++ b/develop-docs/CI.md @@ -13,9 +13,6 @@ Add this job at the start the workflow and then add `need: ready-to-merge-gate` ready-to-merge-gate: name: Ready-to-merge gate uses: ./.github/workflows/ready-to-merge-workflow.yml - with: - is-pr: ${{ github.event_name == 'pull_request' }} - labels: ${{ toJson(github.event.pull_request.labels) }} ``` This job will: