-
-
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.
Moved the release asset upload script to its own file.
- Loading branch information
1 parent
10451a5
commit 0587a43
Showing
2 changed files
with
36 additions
and
25 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,29 @@ | ||
module.exports = async (github, context) => { | ||
const fs = require('fs').promises; | ||
const path = require('path'); | ||
const upload_url = context.payload.release.upload_url; | ||
|
||
if (!upload_url) { | ||
throw "Missing release asset upload URL!"; | ||
} | ||
|
||
for (let filePath of await fs.readdir('.')) { | ||
const fileExtension = path.extname(filePath); | ||
if (fileExtension != '.txt') { | ||
continue; | ||
} | ||
|
||
console.log(`Uploading '${filePath}'`); | ||
const contentLength = (await fs.stat(filePath)).size; | ||
const fileContents = await fs.readFile(filePath); | ||
await github.repos.uploadReleaseAsset({ | ||
url: context.payload.release.upload_url, | ||
headers: { | ||
'content-type': 'application/octet-stream', | ||
'content-length': contentLength | ||
}, | ||
name: path.basename(filePath), | ||
data: fileContents | ||
}); | ||
} | ||
}; |