Skip to content

Commit

Permalink
fix: include retry logic for semantic-release job (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnanand5 authored Oct 16, 2024
1 parent e6603ab commit 5c67114
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5c67114

Please sign in to comment.