Showcase: greenfield BEAR baseline review #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: BEAR CI Governance | |
| on: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| governance: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout demo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Run BEAR governance (observe) | |
| run: ./.bear/ci/bear-gates.sh --mode observe | |
| - name: Publish BEAR PR summary | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = '<!-- bear-ci-governance -->'; | |
| const reportPath = 'build/bear/ci/bear-ci-report.json'; | |
| const summaryPath = 'build/bear/ci/bear-ci-summary.md'; | |
| let body = `${marker}\n## BEAR CI\n\nBEAR did not produce its expected CI report. Check the workflow logs.`; | |
| if (fs.existsSync(reportPath) && fs.existsSync(summaryPath)) { | |
| const report = JSON.parse(fs.readFileSync(reportPath, 'utf8')); | |
| const summary = fs.readFileSync(summaryPath, 'utf8').trim(); | |
| const decision = String(report.decision || 'unknown').toUpperCase().replace(/-/g, ' '); | |
| const mode = report.mode || 'unknown'; | |
| const baseSha = report.resolvedBaseSha || 'unknown'; | |
| body = [ | |
| marker, | |
| '## BEAR CI', | |
| '', | |
| `- Decision: \`${decision}\``, | |
| `- Mode: \`${mode}\``, | |
| `- Base SHA: \`${baseSha}\``, | |
| '', | |
| '<details><summary>BEAR summary</summary>', | |
| '', | |
| summary, | |
| '', | |
| '</details>' | |
| ].join('\n'); | |
| } | |
| const pr = context.payload.pull_request; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| per_page: 100 | |
| }); | |
| const existing = comments.find((comment) => comment.user?.type === 'Bot' && comment.body?.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| body | |
| }); | |
| } | |
| - name: Upload BEAR CI artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bear-ci-governance | |
| path: | | |
| build/bear/ci/bear-ci-report.json | |
| build/bear/ci/bear-ci-summary.md | |
| if-no-files-found: error |