Skip to content

Commit

Permalink
updated asset if already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef committed Sep 3, 2021
1 parent 71cc1d1 commit c77eb15
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,24 @@ jobs:
const { repo: { owner, repo }, sha } = context;
const fs = require('fs').promises;
for (let file of await fs.readdir('./deployment')) {
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ steps.release.outputs.result }},
name: file,
data: await fs.readFile(`./deployment/${file}`)
})
try {
for (let file of await fs.readdir('./deployment')) {
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ steps.release.outputs.result }},
name: file,
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 c77eb15

Please sign in to comment.