|
| 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(); |
0 commit comments