-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cd): attempt on upload artifacts
- Loading branch information
1 parent
a592854
commit 9674efa
Showing
2 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const fs = require('fs').promises; | ||
const { ARTIFACT_NAME, ASSET_NAME, GITHUB_REF } = process.env; | ||
|
||
module.exports = async ({ github, context }) => { | ||
const { | ||
repo: { | ||
owner, | ||
repo, | ||
}, | ||
} = context; | ||
const tag = GITHUB_REF.replace('refs/tags/', ''); | ||
|
||
const release = await github.repos.getReleaseByTag({ | ||
owner, | ||
repo, | ||
tag, | ||
}); | ||
|
||
const files = await fs.readdir('./target/release'); | ||
|
||
for (let file of files) { | ||
if (file === ASSET_NAME) { | ||
await github.repos.uploadReleaseAsset({ | ||
owner, | ||
repo, | ||
release_id: release.data.id, | ||
name: ARTIFACT_NAME, | ||
data: await fs.readFile(file), | ||
}); | ||
} | ||
} | ||
} |