[size-report] migrate to GitHub Actions (#11681)

This commit is contained in:
Yakun Xu
2025-07-14 16:01:32 -07:00
committed by GitHub
parent 579d834e0d
commit f4e239e651
2 changed files with 40 additions and 22 deletions
+35 -5
View File
@@ -32,7 +32,7 @@ on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
pull_request_target:
branches:
- 'main'
@@ -40,12 +40,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
size-report:
permissions:
pull-requests: write
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
@@ -56,8 +55,39 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run
env:
OT_BASE_BRANCH: "${{ github.base_ref }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_NUMBER: "${{ github.event.pull_request.number }}"
run: |
./script/check-size
cat /tmp/ot-size-report/report_pr >> $GITHUB_STEP_SUMMARY
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
name: Post Report
if: ${{ github.event_name == 'pull_request' }}
id: post-report
with:
script: |
const fs = require('fs')
const report = fs.readFileSync('/tmp/ot-size-report/report_pr', 'utf8');
const params = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report,
}
const response = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const kMagicHeader = '<!-- Size Report of **OpenThread** -->'
const comment = response.data.find(comment => comment.body.startsWith(kMagicHeader))
if (comment) {
params.comment_id = comment.id;
await github.rest.issues.updateComment(params)
} else {
await github.rest.issues.createComment(params)
}