Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/ready-to-merge-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Ready to Merge Workflow
on:
workflow_call:
inputs:
is-pr:
required: false
type: boolean
labels:
required: false
type: string

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: ${{ github.event_name == 'pull_request' }}
id: check-label
uses: actions/github-script@v8
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: ${{ 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: ${{ github.event_name == 'pull_request' && steps.check-label.outputs.label_found == 'true' }}
run: echo "Label present. Proceeding with CI."
- name: Gate passed
if: ${{ github.event_name != 'pull_request' }}
run: echo "Not a PR. Proceeding with CI."
7 changes: 7 additions & 0 deletions .github/workflows/sample-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ env:
BUILD_CACHE_KEY: ${{ inputs.build_cache_key }}

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) }}
job_sample_build:
name: Sample Build (${{ matrix.bump }})
runs-on: macos-latest
needs: ready-to-merge-gate
strategy:
matrix:
include:
Expand Down