Skip to content

Commit 8490de4

Browse files
Copilotmakr-code
andauthored
Consolidate build status tracker bootstrap logic into reusable action
Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
1 parent 42fe286 commit 8490de4

3 files changed

Lines changed: 96 additions & 56 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: 'Bootstrap Build Status Tracker'
2+
3+
description: |
4+
Ensures the CI build status tracker issue exists with the marker
5+
<!-- ci-build:type:build-status -->. If the issue does not exist, creates it
6+
with an initial ci/build-ok label and a bootstrapped status message.
7+
8+
This action is used by scheduled workflows (e.g., build-benchmarks, release-mainline)
9+
to ensure the tracker issue exists before checking build status.
10+
11+
Outputs:
12+
- issue-number: The issue number of the tracker (created or existing)
13+
- action-result: 'created' if issue was created, 'skipped' if already existed
14+
15+
inputs:
16+
repo-token:
17+
description: 'GitHub token with issues:write permission'
18+
required: true
19+
20+
outputs:
21+
issue-number:
22+
description: 'Number of the build status tracker issue'
23+
value: ${{ steps.bootstrap.outputs.issue_number }}
24+
action-result:
25+
description: "'created' if issue was created, 'skipped' if already existed"
26+
value: ${{ steps.bootstrap.outputs.action_result }}
27+
28+
runs:
29+
using: composite
30+
steps:
31+
- name: Bootstrap build status tracker issue
32+
id: bootstrap
33+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
34+
with:
35+
github-token: ${{ inputs.repo-token }}
36+
script: |
37+
const marker = '<!-- ci-build:type:build-status -->';
38+
const { owner, repo } = context.repo;
39+
40+
const out = {
41+
issue_number: '',
42+
action_result: 'skipped',
43+
};
44+
45+
const setOutputs = () => {
46+
core.setOutput('issue_number', out.issue_number);
47+
core.setOutput('action_result', out.action_result);
48+
};
49+
50+
// Search for existing tracker issue
51+
const allIssues = await github.paginate(github.rest.issues.listForRepo, {
52+
owner, repo, state: 'open', per_page: 100,
53+
});
54+
const tracker = allIssues.find(i => (i.body || '').includes(marker));
55+
56+
if (tracker) {
57+
// Issue already exists
58+
out.issue_number = String(tracker.number);
59+
out.action_result = 'skipped';
60+
core.notice(`Build tracker issue #${tracker.number} already exists; skipping bootstrap.`);
61+
setOutputs();
62+
return;
63+
}
64+
65+
// Create new tracker issue with bootstrap status
66+
try {
67+
const created = await github.rest.issues.create({
68+
owner,
69+
repo,
70+
title: '[CI] Build status tracker — develop',
71+
body: [
72+
'<!-- ci-build:type:build-status -->',
73+
'## CI Build Status — `develop`',
74+
'',
75+
'Current status: **✅ bootstrapped (no prior build recorded)**',
76+
'',
77+
'_This issue was auto-created because no tracker issue existed._',
78+
'_Labels: `ci/build-failed` + `ci/compiler-linker-failed` = compiler/linker blocker; `ci/test-failed` = non-build blocker; `status/build-pending` = in progress._',
79+
].join('\n'),
80+
labels: ['ci/build-ok'],
81+
});
82+
83+
out.issue_number = String(created.data.number);
84+
out.action_result = 'created';
85+
core.notice(`Bootstrapped build tracker issue #${created.data.number} with ci/build-ok label.`);
86+
} catch (error) {
87+
core.setFailed(`Failed to bootstrap build tracker issue: ${error.message}`);
88+
setOutputs();
89+
return;
90+
}
91+
92+
setOutputs();

‎.github/workflows/build-benchmarks.yml‎

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,9 @@ jobs:
7777
steps:
7878
- name: Bootstrap build tracker issue (schedule gate)
7979
if: github.event_name == 'schedule'
80-
uses: actions/github-script@v7 # v9.0.0
80+
uses: ./.github/actions/bootstrap-build-tracker
8181
with:
82-
github-token: ${{ secrets.GITHUB_TOKEN }}
83-
script: |
84-
const marker = '<!-- ci-build:type:build-status -->';
85-
const { owner, repo } = context.repo;
86-
const allIssues = await github.paginate(github.rest.issues.listForRepo, {
87-
owner, repo, state: 'open', per_page: 100,
88-
});
89-
const tracker = allIssues.find(i => (i.body || '').includes(marker));
90-
if (!tracker) {
91-
const created = await github.rest.issues.create({
92-
owner, repo,
93-
title: '[CI] Build status tracker — develop',
94-
body: [
95-
'<!-- ci-build:type:build-status -->',
96-
'## CI Build Status — `develop`',
97-
'',
98-
'Current status: **✅ bootstrapped (no prior build recorded)**',
99-
'',
100-
'_This issue was auto-created by benchmark preflight because no tracker issue existed._',
101-
'_Labels: `ci/build-failed` + `ci/compiler-linker-failed` = compiler/linker blocker; `ci/test-failed` = non-build blocker; `status/build-pending` = in progress._',
102-
].join('\n'),
103-
labels: ['ci/build-ok'],
104-
});
105-
core.notice(`Bootstrapped build tracker issue #${created.data.number} with ci/build-ok label.`);
106-
} else {
107-
core.notice(`Build tracker issue #${tracker.number} already exists; skipping bootstrap.`);
108-
}
82+
repo-token: ${{ secrets.GITHUB_TOKEN }}
10983
- uses: actions/checkout@v4 # v4.2.2
11084
with:
11185
sparse-checkout: .github/actions/check-build-status

‎.github/workflows/release-mainline.yml‎

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,9 @@ jobs:
7979
steps:
8080
- name: Bootstrap build tracker issue (schedule gate)
8181
if: github.event_name == 'schedule'
82-
uses: actions/github-script@v7 # v9.0.0
82+
uses: ./.github/actions/bootstrap-build-tracker
8383
with:
84-
github-token: ${{ secrets.GITHUB_TOKEN }}
85-
script: |
86-
const marker = '<!-- ci-build:type:build-status -->';
87-
const { owner, repo } = context.repo;
88-
const allIssues = await github.paginate(github.rest.issues.listForRepo, {
89-
owner, repo, state: 'open', per_page: 100,
90-
});
91-
const tracker = allIssues.find(i => (i.body || '').includes(marker));
92-
if (!tracker) {
93-
const created = await github.rest.issues.create({
94-
owner, repo,
95-
title: '[CI] Build status tracker \u2014 develop',
96-
body: [
97-
'<!-- ci-build:type:build-status -->',
98-
'## CI Build Status \u2014 `develop`',
99-
'',
100-
'Current status: **\u2705 bootstrapped (no prior build recorded)**',
101-
'',
102-
'_This issue was auto-created by the release preflight because no tracker issue existed._',
103-
'_Labels: `ci/build-failed` + `ci/compiler-linker-failed` = compiler/linker blocker; `ci/test-failed` = non-build blocker; `status/build-pending` = in progress._',
104-
].join('\n'),
105-
labels: ['ci/build-ok'],
106-
});
107-
core.notice(`Bootstrapped build tracker issue #${created.data.number} with ci/build-ok label.`);
108-
} else {
109-
core.notice(`Build tracker issue #${tracker.number} already exists; skipping bootstrap.`);
110-
}
84+
repo-token: ${{ secrets.GITHUB_TOKEN }}
11185
- name: Checkout (sparse — action only)
11286
if: github.event_name == 'schedule'
11387
uses: actions/checkout@v4 # v4.2.2

0 commit comments

Comments
 (0)