Skip to content

Commit

Permalink
updated release assets upload error
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef committed Sep 6, 2021
1 parent b43bb37 commit cde6e35
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
release_id = release.data.id;
} catch (e) {
let latest;
if (e.code == 422) { // Release alredy exists
if (e.status == 422) { // Release alredy exists
latest = await github.repos.getLatestRelease({
owner, repo
});
Expand All @@ -68,6 +68,19 @@ jobs:
const fs = require('fs').promises;
try {
let asset_ids = await github.repos.listReleaseAssets({
owner, repo,
release_id: ${{ steps.release.outputs.result }}
})
for (let asset of asset_ids.data) {
await github.repos.deleteReleaseAsset({
owner, repo,
asset_id: asset.id
});
}
} catch (e) {
console.log(e.status);
} finally {
for (let file of await fs.readdir('./deployment')) {
await github.repos.uploadReleaseAsset({
owner, repo,
Expand All @@ -76,15 +89,4 @@ jobs:
data: await fs.readFile(`./deployment/${file}`)
})
}
} catch (e) {
if (e.code == 422) { // Asset alredy exists
for (let file of await fs.readdir('./deployment')) {
await github.repos.updateReleaseAsset({
owner, repo,
release_id: ${{ steps.release.outputs.result }},
name: file,
data: await fs.readFile(`./deployment/${file}`)
})
}
}
}
}

0 comments on commit cde6e35

Please sign in to comment.