From 5c6711465f90e3a18fde5e7ec6e8d24eac778a8f Mon Sep 17 00:00:00 2001 From: Krishna Anandan Ganesan Date: Tue, 15 Oct 2024 19:28:39 -0500 Subject: [PATCH] fix: include retry logic for semantic-release job (#577) --- .github/workflows/release.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3bb8a3fef..c6095ad91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,8 +38,26 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run semantic-release + uses: actions/github-script@v6 + with: + script: | + const exec = require('@actions/exec'); + const maxRetry = 3; + const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); + for (let attempt = 1; attempt <= maxRetry; attempt++) { + try { + await exec.exec('yarn', ['semantic-release']); + break; + } catch (error) { + if (attempt < maxRetry) { + console.error(`Attempt ${attempt} failed. Retrying in 60 seconds...`); + await delay(60000); + } else { + throw error; + } + } + } env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: yarn semantic-release \ No newline at end of file