refactor: migrate building blocks to meshstack_building_block #127
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: Scorecard Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| concurrency: | |
| group: scorecard-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| scorecard: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # required for three-dot git diff to find the merge base | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Run scorecard on changed modules | |
| run: | | |
| bash tools/scorecard/pr-scorecard.sh \ | |
| --base="origin/${{ github.base_ref }}" \ | |
| --output="$GITHUB_WORKSPACE/scorecard_report.md" | |
| - name: Post or update PR comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const reportPath = path.join(process.env.GITHUB_WORKSPACE, 'scorecard_report.md'); | |
| let report = fs.readFileSync(reportPath, 'utf8').trim(); | |
| const MAX = 60000; | |
| if (report.length > MAX) { | |
| report = report.slice(0, MAX) + '\n\n_...output truncated_'; | |
| } | |
| const MARKER = '<!-- scorecard-check -->'; | |
| const body = `${MARKER}\n## Scorecard Check\n\n${report}`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find(c => c.body.includes(MARKER)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| core.info(`Updated scorecard comment ${existing.id}`); | |
| } else { | |
| const { data: comment } = await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| core.info(`Created scorecard comment ${comment.id}`); | |
| } |