Skip to content

mirrord action that triggers operator e2e workflow on release PR. #9

mirrord action that triggers operator e2e workflow on release PR.

mirrord action that triggers operator e2e workflow on release PR. #9

Workflow file for this run

name: Operator E2E Test
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
inputs:
mirrord_commit:
description: 'Mirrord commit to use for E2E tests'
required: true
type: string
mirrord_branch:
description: 'Mirrord branch to use for E2E tests'
required: true
type: string
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
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)
steps:
- name: Trigger operator E2E workflow
uses: actions/github-script@v7
with:
script: |
const { Octokit } = require("@octokit/core");
// Get the mirrord commit and branch based on the trigger type
let mirrord_commit, mirrord_branch;
if (github.event_name === 'workflow_dispatch') {
mirrord_commit = github.event.inputs.mirrord_commit;
mirrord_branch = github.event.inputs.mirrord_branch;
} else {
mirrord_commit = context.sha;
mirrord_branch = github.event.pull_request.head.ref;
}
console.log(`Using mirrord commit: ${mirrord_commit}`);
console.log(`Using mirrord branch: ${mirrord_branch}`);
// Octokit.js
// https://github.com/octokit/core.js#readme
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN
})
await octokit.request('POST /repos/metalbear-co/operator/dispatches', {
owner: 'metalbear-co',
repo: 'operator',
event_type: 'operator-e2e-test-from-mirrord',
client_payload: {
mirrord_commit,
mirrord_branch
},
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})