code-foundry 1.44.10 → 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -202,11 +202,15 @@ jobs:
202
202
  write_ok=false
203
203
  if [ "$HAS_AUTOMATION_TOKEN" = true ] && gh api "repos/${GITHUB_REPOSITORY}" --jq '.full_name' >/dev/null 2>&1; then
204
204
  probe_ref="refs/tags/token-write-probe-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
205
- if gh api -X POST "repos/${GITHUB_REPOSITORY}/git/refs" \
206
- -f "ref=$probe_ref" -f "sha=${GITHUB_SHA}" >/dev/null 2>&1; then
207
- gh api -X DELETE "repos/${GITHUB_REPOSITORY}/git/refs/tags/token-write-probe-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >/dev/null 2>&1 || true
208
- write_ok=true
209
- fi
205
+ for wait in 0 10 30; do
206
+ sleep "$wait"
207
+ if gh api -X POST "repos/${GITHUB_REPOSITORY}/git/refs" \
208
+ -f "ref=$probe_ref" -f "sha=${GITHUB_SHA}" >/dev/null 2>&1; then
209
+ gh api -X DELETE "repos/${GITHUB_REPOSITORY}/git/refs/tags/token-write-probe-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >/dev/null 2>&1 || true
210
+ write_ok=true
211
+ break
212
+ fi
213
+ done
210
214
  fi
211
215
  if [ "$write_ok" = true ]; then
212
216
  echo "auto_merge=true" >> "$GITHUB_OUTPUT"
@@ -262,8 +266,28 @@ jobs:
262
266
  const { execFileSync } = require('node:child_process');
263
267
  const fs = require('node:fs');
264
268
 
265
- const gh = (args) =>
266
- execFileSync('gh', args, { encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 });
269
+ const sleep = (seconds) =>
270
+ execFileSync('sleep', [String(seconds)]);
271
+ // Writes intermittently hit GitHub's secondary rate limiting from
272
+ // busy automation accounts (403 with the generic not-accessible
273
+ // message); back off and retry before giving up.
274
+ const gh = (args) => {
275
+ for (const wait of [0, 10, 30]) {
276
+ try {
277
+ if (wait) sleep(wait);
278
+ return execFileSync('gh', args, {
279
+ encoding: 'utf8',
280
+ maxBuffer: 32 * 1024 * 1024,
281
+ });
282
+ } catch (error) {
283
+ const status = error.status;
284
+ const retriable = status === null || status === 403 || status === 429 || status >= 500;
285
+ if (!retriable || wait === 30) throw error;
286
+ console.log(`gh call failed (status ${status ?? 'unknown'}); retrying in ${wait === 0 ? 10 : 30}s`);
287
+ }
288
+ }
289
+ throw new Error('unreachable');
290
+ };
267
291
 
268
292
  const repo = process.env.REPOSITORY;
269
293
  const config = JSON.parse(fs.readFileSync(process.env.CONFIG_FILE, 'utf8'));