From 094b5a57de6efcd4e47ccc6d7688e17a3bff321d Mon Sep 17 00:00:00 2001 From: Asahina Mafuyu Date: Thu, 5 Mar 2026 18:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/check_file_size.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_file_size.yml b/.github/workflows/check_file_size.yml index df3b8b2..080a128 100644 --- a/.github/workflows/check_file_size.yml +++ b/.github/workflows/check_file_size.yml @@ -21,6 +21,7 @@ jobs: const prNumber = context.payload.pull_request.number; const owner = context.repo.owner; const repo = context.repo.repo; + const pr = context.payload.pull_request; let page = 1; let oversized = []; @@ -39,10 +40,20 @@ jobs: for (const file of files) { // 只检查新增或修改文件 - if (["added", "modified", "renamed", "copied"].includes(file.status)) { - if (file.size > MAX_SIZE) { - oversized.push(`- ${file.filename} (${file.size} bytes)`); - } + if (!["added","modified","renamed","copied"].includes(file.status)) + continue; + + const content = await github.rest.repos.getContent({ + owner: pr.head.repo.owner.login, + repo: pr.head.repo.name, + path: file.filename, + ref: pr.head.sha + }); + + const size = content.data.size; + + if (size > MAX_SIZE) { + oversized.push(`- ${file.filename} (${size} bytes)`); } }