Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 14 additions & 15 deletions .github/workflows/ready-to-merge-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
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
env:
GH_TOKEN: ${{ github.token }}
EXPECTED_LABEL: "ready-to-merge"
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
# Fetch labels from GitHub API
# Looks like GH actions may not contain the labels in the event, so we need to fetch them from the API.
labels=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels --jq '.[].name')
echo "Found labels: $labels"
# Check for exact 'ready-to-merge' label match
if echo "$labels" | grep -q "^${{ env.EXPECTED_LABEL }}$"; then
echo "label_found=true" >> $GITHUB_OUTPUT
else
echo "label_found=false" >> $GITHUB_OUTPUT
fi
# 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