Skip to content

Commit 2be10fc

Browse files
authored
ci: add summary and build all trigger. (#55)
* add build one package * add build all * add build all * fix build all * fix build all * fix build all * fix build all * fix build all
1 parent 842f92f commit 2be10fc

File tree

6 files changed

+537
-6
lines changed

6 files changed

+537
-6
lines changed
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
name: Build All Runtimes
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag for the Docker image'
8+
required: true
9+
default: 'latest'
10+
cn_patch_enabled:
11+
description: 'Enable CN patch modifications'
12+
required: false
13+
default: 'false'
14+
type: boolean
15+
aliyun_enabled:
16+
description: 'Enable Aliyun ACR builds'
17+
required: false
18+
default: 'false'
19+
type: boolean
20+
21+
jobs:
22+
# Step 1: Build OS Runtimes
23+
build-os-runtimes:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
actions: write
28+
steps:
29+
- name: Trigger OS Runtimes Build
30+
id: trigger_os
31+
uses: actions/github-script@v7
32+
with:
33+
script: |
34+
const { data } = await github.rest.actions.createWorkflowDispatch({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
workflow_id: 'build-os-runtimes.yml',
38+
ref: context.ref,
39+
inputs: {
40+
tag: '${{ inputs.tag }}',
41+
cn_patch_enabled: '${{ inputs.cn_patch_enabled }}',
42+
aliyun_enabled: '${{ inputs.aliyun_enabled }}',
43+
}
44+
});
45+
console.log('OS runtimes build triggered:', data);
46+
console.log('Response structure:', JSON.stringify(data, null, 2));
47+
48+
// Wait a moment for the workflow to start
49+
await new Promise(resolve => setTimeout(resolve, 5000));
50+
51+
// Get the latest workflow run (should be the one we just triggered)
52+
const { data: workflows } = await github.rest.actions.listWorkflowRuns({
53+
owner: context.repo.owner,
54+
repo: context.repo.repo,
55+
workflow_id: 'build-os-runtimes.yml',
56+
ref: context.ref,
57+
per_page: 1
58+
});
59+
60+
if (workflows.workflow_runs.length === 0) {
61+
throw new Error('No OS runtimes workflow found after triggering');
62+
}
63+
64+
const workflowRun = workflows.workflow_runs[0];
65+
console.log(`Found triggered OS runtimes workflow run: ${workflowRun.id}`);
66+
67+
// Store the workflow run ID for direct monitoring
68+
core.setOutput('os_workflow_run_id', workflowRun.id);
69+
- name: Wait for OS Runtimes to complete
70+
uses: actions/github-script@v7
71+
with:
72+
script: |
73+
const workflowRunId = '${{ steps.trigger_os.outputs.os_workflow_run_id }}';
74+
console.log(`Monitoring OS runtimes workflow run: ${workflowRunId}`);
75+
76+
// Wait for workflow to complete
77+
let attempts = 0;
78+
const maxAttempts = 180; // 60 minutes with 10s intervals
79+
80+
while (attempts < maxAttempts) {
81+
const { data: run } = await github.rest.actions.getWorkflowRun({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
run_id: workflowRunId
85+
});
86+
87+
console.log(`Workflow status: ${run.status}, conclusion: ${run.conclusion}`);
88+
89+
if (run.status === 'completed') {
90+
if (run.conclusion === 'success') {
91+
console.log('✅ OS Runtimes workflow completed successfully');
92+
return;
93+
} else {
94+
throw new Error(`❌ OS Runtimes workflow failed with conclusion: ${run.conclusion}`);
95+
}
96+
}
97+
98+
console.log(`Waiting for OS runtimes workflow to complete... (attempt ${attempts + 1}/${maxAttempts})`);
99+
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
100+
attempts++;
101+
}
102+
103+
throw new Error('Timeout waiting for OS runtimes workflow to complete');
104+
105+
# Step 2: Build Language Runtimes
106+
build-language-runtimes:
107+
runs-on: ubuntu-latest
108+
needs: build-os-runtimes
109+
permissions:
110+
contents: read
111+
actions: write
112+
steps:
113+
- name: Trigger Language Runtimes Build
114+
id: trigger_language
115+
uses: actions/github-script@v7
116+
with:
117+
script: |
118+
const { data } = await github.rest.actions.createWorkflowDispatch({
119+
owner: context.repo.owner,
120+
repo: context.repo.repo,
121+
workflow_id: 'build-language-runtimes.yml',
122+
ref: context.ref,
123+
inputs: {
124+
tag: '${{ inputs.tag }}',
125+
build_base_image: 'ghcr.io/${{ github.repository_owner }}/devbox/debian-12.6:${{ inputs.tag }}',
126+
build_base_image_with_cn_patch: 'ghcr.io/${{ github.repository_owner }}/devbox/debian-12.6:${{ inputs.tag }}-cn',
127+
cn_patch_enabled: '${{ inputs.cn_patch_enabled }}',
128+
aliyun_enabled: '${{ inputs.aliyun_enabled }}'
129+
}
130+
});
131+
console.log('Language runtimes build triggered:', data);
132+
133+
// Wait a moment for the workflow to start
134+
await new Promise(resolve => setTimeout(resolve, 5000));
135+
136+
// Get the latest workflow run (should be the one we just triggered)
137+
const { data: workflows } = await github.rest.actions.listWorkflowRuns({
138+
owner: context.repo.owner,
139+
repo: context.repo.repo,
140+
workflow_id: 'build-language-runtimes.yml',
141+
ref: context.ref,
142+
per_page: 1
143+
});
144+
145+
if (workflows.workflow_runs.length === 0) {
146+
throw new Error('No Language runtimes workflow found after triggering');
147+
}
148+
149+
const workflowRun = workflows.workflow_runs[0];
150+
console.log(`Found triggered Language runtimes workflow run: ${workflowRun.id}`);
151+
152+
// Store the workflow run ID for direct monitoring
153+
core.setOutput('language_workflow_run_id', workflowRun.id);
154+
- name: Wait for Language Runtimes to complete
155+
uses: actions/github-script@v7
156+
with:
157+
script: |
158+
const workflowRunId = '${{ steps.trigger_language.outputs.language_workflow_run_id }}';
159+
console.log(`Monitoring Language runtimes workflow run: ${workflowRunId}`);
160+
161+
// Wait for workflow to complete
162+
let attempts = 0;
163+
const maxAttempts = 180; // 60 minutes with 10s intervals
164+
165+
while (attempts < maxAttempts) {
166+
const { data: run } = await github.rest.actions.getWorkflowRun({
167+
owner: context.repo.owner,
168+
repo: context.repo.repo,
169+
run_id: workflowRunId
170+
});
171+
172+
console.log(`Workflow status: ${run.status}, conclusion: ${run.conclusion}`);
173+
174+
if (run.status === 'completed') {
175+
if (run.conclusion === 'success') {
176+
console.log('✅ Language Runtimes workflow completed successfully');
177+
return;
178+
} else {
179+
throw new Error(`❌ Language Runtimes workflow failed with conclusion: ${run.conclusion}`);
180+
}
181+
}
182+
183+
console.log(`Waiting for Language runtimes workflow to complete... (attempt ${attempts + 1}/${maxAttempts})`);
184+
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
185+
attempts++;
186+
}
187+
188+
throw new Error('Timeout waiting for Language runtimes workflow to complete');
189+
190+
# Step 3: Build Framework Runtimes
191+
build-framework-runtimes:
192+
runs-on: ubuntu-latest
193+
needs: build-language-runtimes
194+
permissions:
195+
contents: read
196+
actions: write
197+
steps:
198+
- name: Trigger Framework Runtimes Build
199+
id: trigger_framework
200+
uses: actions/github-script@v7
201+
with:
202+
script: |
203+
const { data } = await github.rest.actions.createWorkflowDispatch({
204+
owner: context.repo.owner,
205+
repo: context.repo.repo,
206+
workflow_id: 'build-framework-runtimes.yml',
207+
ref: context.ref,
208+
inputs: {
209+
tag: '${{ inputs.tag }}',
210+
build_base_image_tag: '${{ inputs.tag }}',
211+
build_base_image_tag_with_cn_patch: '${{ inputs.tag }}-cn',
212+
cn_patch_enabled: '${{ inputs.cn_patch_enabled }}',
213+
aliyun_enabled: '${{ inputs.aliyun_enabled }}'
214+
}
215+
});
216+
console.log('Framework runtimes build triggered:', data);
217+
218+
// Wait a moment for the workflow to start
219+
await new Promise(resolve => setTimeout(resolve, 5000));
220+
221+
// Get the latest workflow run (should be the one we just triggered)
222+
const { data: workflows } = await github.rest.actions.listWorkflowRuns({
223+
owner: context.repo.owner,
224+
repo: context.repo.repo,
225+
workflow_id: 'build-framework-runtimes.yml',
226+
ref: context.ref,
227+
per_page: 1
228+
});
229+
230+
if (workflows.workflow_runs.length === 0) {
231+
throw new Error('No Framework runtimes workflow found after triggering');
232+
}
233+
234+
const workflowRun = workflows.workflow_runs[0];
235+
console.log(`Found triggered Framework runtimes workflow run: ${workflowRun.id}`);
236+
237+
// Store the workflow run ID for direct monitoring
238+
core.setOutput('framework_workflow_run_id', workflowRun.id);
239+
- name: Wait for Framework Runtimes to complete
240+
uses: actions/github-script@v7
241+
with:
242+
script: |
243+
const workflowRunId = '${{ steps.trigger_framework.outputs.framework_workflow_run_id }}';
244+
console.log(`Monitoring Framework runtimes workflow run: ${workflowRunId}`);
245+
246+
// Wait for workflow to complete
247+
let attempts = 0;
248+
const maxAttempts = 180; // 60 minutes with 10s intervals
249+
250+
while (attempts < maxAttempts) {
251+
const { data: run } = await github.rest.actions.getWorkflowRun({
252+
owner: context.repo.owner,
253+
repo: context.repo.repo,
254+
run_id: workflowRunId
255+
});
256+
257+
console.log(`Workflow status: ${run.status}, conclusion: ${run.conclusion}`);
258+
259+
if (run.status === 'completed') {
260+
if (run.conclusion === 'success') {
261+
console.log('✅ Framework Runtimes workflow completed successfully');
262+
return;
263+
} else {
264+
throw new Error(`❌ Framework Runtimes workflow failed with conclusion: ${run.conclusion}`);
265+
}
266+
}
267+
268+
console.log(`Waiting for Framework runtimes workflow to complete... (attempt ${attempts + 1}/${maxAttempts})`);
269+
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
270+
attempts++;
271+
}
272+
273+
throw new Error('Timeout waiting for Framework runtimes workflow to complete');
274+
275+
# Final step: Summary
276+
build-summary:
277+
runs-on: ubuntu-latest
278+
needs: [build-os-runtimes, build-language-runtimes, build-framework-runtimes]
279+
if: always()
280+
steps:
281+
- name: Build Summary
282+
run: |
283+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
284+
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
285+
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
286+
echo "| OS Runtimes | ${{ needs.build-os-runtimes.result }} |" >> $GITHUB_STEP_SUMMARY
287+
echo "| Language Runtimes | ${{ needs.build-language-runtimes.result }} |" >> $GITHUB_STEP_SUMMARY
288+
echo "| Framework Runtimes | ${{ needs.build-framework-runtimes.result }} |" >> $GITHUB_STEP_SUMMARY
289+
290+
if [[ "${{ needs.build-os-runtimes.result }}" == "success" && "${{ needs.build-language-runtimes.result }}" == "success" && "${{ needs.build-framework-runtimes.result }}" == "success" ]]; then
291+
echo "✅ All runtimes built successfully!"
292+
else
293+
echo "❌ Some runtimes failed to build"
294+
exit 1
295+
fi

.github/workflows/build-framework-runtimes.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ on:
2121
description: 'Enable CN patch modifications'
2222
required: false
2323
default: 'false'
24+
type: boolean
2425
aliyun_enabled:
2526
description: 'Enable Aliyun ACR builds'
2627
required: false
2728
default: 'false'
29+
type: boolean
2830

2931
jobs:
3032
# Define framework runtime matrix

.github/workflows/build-language-runtimes.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ on:
1919
description: 'Enable CN patch modifications'
2020
required: false
2121
default: 'false'
22+
type: boolean
2223
aliyun_enabled:
2324
description: 'Enable Aliyun ACR builds'
2425
required: false
2526
default: 'false'
26-
27+
type: boolean
2728
jobs:
2829
# Define language runtime matrix
2930
define-matrix:
@@ -123,6 +124,20 @@ jobs:
123124
aliyun_credentials: ${{ inputs.aliyun_enabled == 'true' && format('{{"registry":"{0}","username":"{1}","password":"{2}", "namespace":"{3}"}}', secrets.ALIYUN_REGISTRY, secrets.ALIYUN_USERNAME, secrets.ALIYUN_PASSWORD, secrets.ALIYUN_NAMESPACE) || '{}' }}
124125
acr_image_name: ${{ steps.generate-standard.outputs.acr_image_name }}
125126
build_base_image: ${{ needs.define-matrix.outputs.build_base_image }}
127+
- name: Output built image names (standard)
128+
run: |
129+
echo "## 🐳 Built Language Runtime Images (Standard)" >> $GITHUB_STEP_SUMMARY
130+
echo "| Image Name | Registry |" >> $GITHUB_STEP_SUMMARY
131+
echo "|------------|----------|" >> $GITHUB_STEP_SUMMARY
132+
echo "| ${{ steps.generate-standard.outputs.ghcr_image_name }} | GHCR |" >> $GITHUB_STEP_SUMMARY
133+
if [ "${{ steps.generate-standard.outputs.acr_image_name }}" != "" ]; then
134+
echo "| ${{ steps.generate-standard.outputs.acr_image_name }} | Aliyun ACR |" >> $GITHUB_STEP_SUMMARY
135+
fi
136+
echo "" >> $GITHUB_STEP_SUMMARY
137+
echo "### 🚀 Pull Command" >> $GITHUB_STEP_SUMMARY
138+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
139+
echo "docker pull ${{ steps.generate-standard.outputs.ghcr_image_name }}" >> $GITHUB_STEP_SUMMARY
140+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
126141
- name: Generate image names (cn-patched)
127142
id: generate-cn
128143
if: ${{ needs.define-matrix.outputs.cn_patch_enabled == 'true' }}
@@ -143,3 +158,18 @@ jobs:
143158
aliyun_credentials: ${{ inputs.aliyun_enabled == 'true' && format('{{"registry":"{0}","username":"{1}","password":"{2}", "namespace":"{3}"}}', secrets.ALIYUN_REGISTRY, secrets.ALIYUN_USERNAME, secrets.ALIYUN_PASSWORD, secrets.ALIYUN_NAMESPACE) || '{}' }}
144159
ghcr_image_name: ${{ steps.generate-cn.outputs.ghcr_image_name }}
145160
acr_image_name: ${{ steps.generate-cn.outputs.acr_image_name }}
161+
- name: Output built image names (cn-patched)
162+
if: ${{ needs.define-matrix.outputs.cn_patch_enabled == 'true' }}
163+
run: |
164+
echo "## 🐳 Built Language Runtime Images (CN-Patched)" >> $GITHUB_STEP_SUMMARY
165+
echo "| Image Name | Registry |" >> $GITHUB_STEP_SUMMARY
166+
echo "|------------|----------|" >> $GITHUB_STEP_SUMMARY
167+
echo "| ${{ steps.generate-cn.outputs.ghcr_image_name }} | GHCR |" >> $GITHUB_STEP_SUMMARY
168+
if [ "${{ steps.generate-cn.outputs.acr_image_name }}" != "" ]; then
169+
echo "| ${{ steps.generate-cn.outputs.acr_image_name }} | Aliyun ACR |" >> $GITHUB_STEP_SUMMARY
170+
fi
171+
echo "" >> $GITHUB_STEP_SUMMARY
172+
echo "### 🚀 Pull Command" >> $GITHUB_STEP_SUMMARY
173+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
174+
echo "docker pull ${{ steps.generate-cn.outputs.ghcr_image_name }}" >> $GITHUB_STEP_SUMMARY
175+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)