mirrord action that triggers operator e2e workflow on release PR. #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Operator E2E Test | |
on: | |
# Run when PR is opened or has new commits | |
pull_request: | |
types: [opened, synchronize] | |
# Allow manual triggering | |
workflow_dispatch: | |
jobs: | |
trigger-operator-e2e: | |
runs-on: ubuntu-latest | |
# Only run if: | |
# 1. PR is opened and not draft | |
# 2. PR has new code and not draft | |
# 3. Manually triggered | |
# 4. PR title contains a version number (e.g. "Release v3.132.0") | |
if: | | |
github.event_name == 'workflow_dispatch' || | |
(github.event.action == 'opened' && github.event.pull_request.draft == false) || | |
(github.event.action == 'synchronize' && | |
github.event.pull_request.draft == false && | |
contains(github.event.pull_request.title, 'Release v')) | |
steps: | |
- name: Trigger operator E2E workflow | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: workflow } = await github.rest.actions.createWorkflowDispatch({ | |
owner: 'metalbear-co', | |
repo: 'operator', | |
workflow_id: 'operator-e2e.yaml', | |
ref: 'main', // Keep main as ref since we want to test against main operator | |
inputs: { | |
mirrord_commit: context.sha, | |
mirrord_branch: github.event.pull_request.head.ref // Pass the PR's branch | |
} | |
}); | |
// Poll for workflow completion | |
let status = 'queued'; | |
let attempts = 0; | |
const maxAttempts = 40; // 20 minutes with 30s intervals | |
while (status === 'queued' || status === 'in_progress') { | |
if (attempts >= maxAttempts) { | |
throw new Error('Operator E2E tests timed out after 20 minutes'); | |
} | |
await new Promise(resolve => setTimeout(resolve, 30000)); // Wait 30 seconds | |
const { data: runs } = await github.rest.actions.listWorkflowRuns({ | |
owner: 'metalbear-co', | |
repo: 'operator', | |
workflow_id: 'operator-e2e.yaml', | |
branch: 'main', | |
per_page: 1 | |
}); | |
if (runs.workflow_runs.length > 0) { | |
status = runs.workflow_runs[0].conclusion; | |
if (status === 'success') { | |
console.log('Operator E2E tests passed'); | |
return; | |
} else if (status === 'failure') { | |
// Don't fail the workflow, just log the failure | |
console.log('Operator E2E tests failed'); | |
return; | |
} | |
} | |
attempts++; | |
} | |
throw new Error('Operator E2E tests timed out'); |