Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 23 additions & 20 deletions .github/workflows/ready-to-merge-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
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:
name: 'Missing "ready-to-merge" label'
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."
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ui-tests-critical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions develop-docs/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading