Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Add retry loop to fetch-artifact action's download step (#70513)

mendral-app[bot]214c38b3f216
diff --git a/.github/actions/fetch-artifact/action.yml b/.github/actions/fetch-artifact/action.yml
index dfbe47f322e..836bdbd8cd5 100644
--- a/.github/actions/fetch-artifact/action.yml
+++ b/.github/actions/fetch-artifact/action.yml
@@ -51,12 +51,25 @@ runs:
const artifact_id = artifacts.data.artifacts[0].id;
- const download = await github.rest.actions.downloadArtifact({
- owner: context.repo.owner,
- repo: context.repo.repo,
- artifact_id: artifact_id,
- archive_format: 'zip',
- });
+ let download;
+ const maxAttempts = 3;
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
+ try {
+ download = await github.rest.actions.downloadArtifact({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ artifact_id: artifact_id,
+ archive_format: 'zip',
+ });
+ break;
+ } catch (err) {
+ console.log(`Attempt ${attempt}/${maxAttempts} failed: ${err.message}`);
+ if (attempt === maxAttempts) throw err;
+ const delay = attempt * 15000; // 15s, 30s
+ console.log(`Retrying in ${delay / 1000}s...`);
+ await new Promise(r => setTimeout(r, delay));
+ }
+ }
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/mb.zip`, Buffer.from(download.data));