Skip to content

Commit 39c969f

Browse files
committed
fix(e2e): bootstrap through registered Omarchy workflow
1 parent a539f00 commit 39c969f

2 files changed

Lines changed: 47 additions & 49 deletions

File tree

‎.github/workflows/bootstrap-midscene-review.yml‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎.github/workflows/midscene-omarchy-4.0.3.yml‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ on:
4444
types: [labeled]
4545
workflow_dispatch:
4646
inputs:
47+
bootstrap_hosted_model:
48+
description: Transfer the existing hosted model secret to the Midscene App
49+
type: boolean
50+
required: false
51+
default: false
4752
project:
4853
description: Run one Midscene project for focused verification
4954
type: choice
@@ -94,9 +99,49 @@ concurrency:
9499
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
95100

96101
jobs:
102+
bootstrap-hosted-model:
103+
name: Bootstrap hosted model
104+
if: github.event_name == 'workflow_dispatch' && inputs.bootstrap_hosted_model == true && github.actor == 'quanru' && github.ref == 'refs/heads/research/omarchy-plugin-visual-review'
105+
runs-on: ubuntu-latest
106+
timeout-minutes: 5
107+
env:
108+
MIDSCENE_REVIEW_APP_URL: ${{ vars.MIDSCENE_REVIEW_APP_URL }}
109+
HOSTED_MODEL_API_KEY: ${{ secrets.MIDSCENE_MODEL_API_KEY }}
110+
HOSTED_MODEL_NAME: ${{ secrets.MIDSCENE_MODEL_NAME }}
111+
HOSTED_MODEL_BASE_URL: ${{ secrets.MIDSCENE_MODEL_BASE_URL }}
112+
HOSTED_MODEL_FAMILY: ${{ secrets.MIDSCENE_MODEL_FAMILY }}
113+
steps:
114+
- name: Transfer hosted model configuration over OIDC-authenticated HTTPS
115+
run: |
116+
test -n "$MIDSCENE_REVIEW_APP_URL"
117+
test -n "$HOSTED_MODEL_API_KEY"
118+
test -n "$HOSTED_MODEL_NAME"
119+
test -n "$HOSTED_MODEL_BASE_URL"
120+
test -n "$HOSTED_MODEL_FAMILY"
121+
node --input-type=module <<'JS'
122+
const identityResponse = await fetch(`${process.env.ACTIONS_ID_TOKEN_REQUEST_URL}&audience=midscene-review-app`, {
123+
headers: { authorization: `bearer ${process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}` },
124+
});
125+
if (!identityResponse.ok) throw new Error(`GitHub OIDC failed: ${identityResponse.status}`);
126+
const { value: identity } = await identityResponse.json();
127+
const response = await fetch(`${process.env.MIDSCENE_REVIEW_APP_URL.replace(/\/+$/, '')}/api/worker/bootstrap-hosted`, {
128+
method: 'POST',
129+
headers: { authorization: `Bearer ${identity}`, 'content-type': 'application/json' },
130+
body: JSON.stringify({
131+
apiKey: process.env.HOSTED_MODEL_API_KEY,
132+
modelName: process.env.HOSTED_MODEL_NAME,
133+
baseUrl: process.env.HOSTED_MODEL_BASE_URL,
134+
modelFamily: process.env.HOSTED_MODEL_FAMILY,
135+
}),
136+
});
137+
if (!response.ok) throw new Error(`Midscene bootstrap failed: ${response.status}`);
138+
console.log('Hosted model configuration was stored by the Midscene review service.');
139+
JS
140+
97141
omarchy-e2e:
98142
name: Midscene visual (${{ matrix.project }})
99143
if: >-
144+
inputs.bootstrap_hosted_model != true &&
100145
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) &&
101146
(github.event_name != 'issues' ||
102147
(github.event.label.name == 'midscene-review' && startsWith(github.event.issue.title, '[Omarchy review] ')))
@@ -344,7 +389,7 @@ jobs:
344389
name: Assemble Midscene report bundle
345390
needs: omarchy-e2e
346391
if: >-
347-
always() && !cancelled() && github.event_name != 'issues' &&
392+
always() && !cancelled() && github.event_name != 'issues' && inputs.bootstrap_hosted_model != true &&
348393
(inputs.project == '' || inputs.project == 'all')
349394
runs-on: ubuntu-latest
350395
outputs:
@@ -380,7 +425,7 @@ jobs:
380425
name: GitHub Pages report
381426
needs: [omarchy-e2e, report-bundle]
382427
if: >-
383-
always() && github.event_name != 'issues' &&
428+
always() && github.event_name != 'issues' && inputs.bootstrap_hosted_model != true &&
384429
!cancelled() &&
385430
needs.report-bundle.outputs.report-artifact-id != '' &&
386431
(github.event_name != 'pull_request' ||

0 commit comments

Comments
 (0)