Retry the entire release process, not just uploading one asset (#989)
Another attempt to mitigate #978
This commit is contained in:
14
.github/actions/github-release/main.js
vendored
14
.github/actions/github-release/main.js
vendored
@@ -8,7 +8,7 @@ function sleep(milliseconds) {
|
||||
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
||||
}
|
||||
|
||||
async function run() {
|
||||
async function runOnce() {
|
||||
// Load all our inputs and env vars. Note that `getInput` reads from `INPUT_*`
|
||||
const files = core.getInput('files');
|
||||
const name = core.getInput('name');
|
||||
@@ -76,18 +76,23 @@ async function run() {
|
||||
});
|
||||
|
||||
// Upload all the relevant assets for this release as just general blobs.
|
||||
const retries = 10;
|
||||
for (const file of glob.sync(files)) {
|
||||
const size = fs.statSync(file).size;
|
||||
core.info(`upload ${file}`);
|
||||
for (let i = 0; i < retries; i++) {
|
||||
try {
|
||||
await octokit.repos.uploadReleaseAsset({
|
||||
data: fs.createReadStream(file),
|
||||
headers: { 'content-length': size, 'content-type': 'application/octet-stream' },
|
||||
name: path.basename(file),
|
||||
url: release.data.upload_url,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const retries = 10;
|
||||
for (let i = 0; i < retries; i++) {
|
||||
try {
|
||||
runOnce();
|
||||
break;
|
||||
} catch (e) {
|
||||
if (i === retries - 1)
|
||||
@@ -99,7 +104,6 @@ async function run() {
|
||||
await sleep(10000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run().catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user