fix(ci): skip AI review when quota is unavailable

This commit is contained in:
Tunglies
2026-08-22 14:54:57 +08:00
parent c009de42a1
commit b58ffc909b
4 changed files with 475 additions and 319 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
.github/workflows/*.lock.yml linguist-generated=true merge=ours
.github/workflows/*.lock.yml linguist-generated=true
Changelog.md merge=union
+3 -3
View File
@@ -5,10 +5,10 @@
"version": "v9.0.0",
"sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3"
},
"github/gh-aw-actions/setup@v0.83.4": {
"github/gh-aw-actions/setup@v0.87.4": {
"repo": "github/gh-aw-actions/setup",
"version": "v0.83.4",
"sha": "e89c65e17eb281bbd5ff2ff9e9199a03e96654c7"
"version": "v0.87.4",
"sha": "ea4b911d44a5336c74325a122a5fd9110b45ff06"
},
"github/gh-aw/actions/setup@v0.74.8": {
"repo": "github/gh-aw/actions/setup",
File diff suppressed because one or more lines are too long
+31
View File
@@ -12,10 +12,41 @@ on:
workflow_dispatch:
checkout: false
max-daily-ai-credits: 5000
permissions:
issues: read
pull-requests: read
pre-agent-steps:
- name: Make Copilot quota exhaustion non-blocking
run: |
node <<'NODE'
const fs = require('fs');
const harnessPath = `${process.env.RUNNER_TEMP}/gh-aw/actions/copilot_harness.cjs`;
const harness = fs.readFileSync(harnessPath, 'utf8');
const quotaBranch = [
' if (isQuotaExceeded) {',
' log(`attempt ${attempt + 1}: Copilot quota exceeded — not retrying`);',
' return { action: "stop" };',
' }',
].join('\n');
const nonBlockingQuotaBranch = [
' if (isQuotaExceeded) {',
' log(`attempt ${attempt + 1}: Copilot quota exceeded — not retrying`);',
' if (/\\b429\\b|Too Many Requests/i.test(result.output)) {',
' log(`attempt ${attempt + 1}: Copilot quota unavailable — exiting 0`);',
' return { action: "stop", exitCode: 0 };',
' }',
' return { action: "stop" };',
' }',
].join('\n');
if (harness.split(quotaBranch).length !== 2) {
throw new Error('Unexpected Copilot quota branch; re-audit the gh-aw upgrade');
}
fs.writeFileSync(harnessPath, harness.replace(quotaBranch, nonBlockingQuotaBranch));
NODE
tools:
github:
toolsets: [issues, pull_requests]