diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6714295..0300e2fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,6 +145,8 @@ jobs: - name: Install Rust run: rustup toolchain add nightly --no-self-update && rustup default nightly - run: tools/manifest.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: git add -N . && git diff --exit-code if: github.repository_owner != 'taiki-e' || github.event_name != 'schedule' && !(github.event_name == 'push' && github.ref == 'refs/heads/main') - id: diff diff --git a/main.sh b/main.sh index 4019fee1..bd586dff 100755 --- a/main.sh +++ b/main.sh @@ -11,7 +11,7 @@ x() { ) } retry() { - for i in {1..5}; do + for i in {1..10}; do if "$@"; then return 0 else diff --git a/tools/codegen/src/main.rs b/tools/codegen/src/main.rs index a5f3a502..18b67afd 100644 --- a/tools/codegen/src/main.rs +++ b/tools/codegen/src/main.rs @@ -385,24 +385,32 @@ fn replace_vars(s: &str, package: &str, version: &str, platform: HostPlatform) - } fn download(url: &str) -> Result { - let token = env::var("INTERNAL_CODEGEN_GH_PAT").ok(); + let mut token1 = env::var("INTERNAL_CODEGEN_GH_PAT").ok().filter(|v| !v.is_empty()); + let mut token2 = env::var("GITHUB_TOKEN").ok().filter(|v| !v.is_empty()); let mut retry = 0; let mut last_error; loop { let mut req = ureq::get(url); - if let Some(token) = &token { + if let Some(token) = &token1 { + req = req.set("Authorization", token); + } else if let Some(token) = &token2 { req = req.set("Authorization", token); } match req.call() { Ok(res) => return Ok(res), Err(e) => last_error = Some(e), } + if token1.is_some() { + token1 = None; + } else if token2.is_some() { + token2 = None; + } retry += 1; - if retry > 5 { + if retry > 10 { break; } - eprintln!("download failed; retrying ({retry}/5)"); - std::thread::sleep(Duration::from_secs(retry * 2)); + eprintln!("download failed; retrying ({retry}/10)"); + std::thread::sleep(Duration::from_secs(retry * 4)); } Err(last_error.unwrap().into()) }