Skip to content

Commit 59cbfd5

Browse files
committed
github-release(download): ensure to request a binary download
Some GitHub REST API calls will strangely think that you prefer a JSON when you want to get, say, a release asset... unless you specifically ask for a binary download. Tsk, tsk. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 60ac230 commit 59cbfd5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

github-release.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ const getWorkflowRunArtifactsURLs = async (context, token, owner, repo, workflow
6060

6161
const download = async (token, url, outputFile) => {
6262
const { spawnSync } = require('child_process')
63-
const auth = token ? ['-H', `Authorization: Bearer ${token}`] : []
64-
const curl = spawnSync('curl', [...auth, '-Lo', outputFile, url])
63+
const headers = token ? ['-H', `Authorization: Bearer ${token}`] : []
64+
if (url.match(/^https:\/\/github.com\/[^/]+\/[^/]+\/releases\/assets\/\d+$/)
65+
|| url.match(/^https:\/\/api\.github.com\/repos\/[^/]+\/[^/]+\/releases\/assets\/\d+$/)) {
66+
headers.push('-H', 'Accept: application/octet-stream')
67+
}
68+
const curl = spawnSync('curl', [...headers, '-fLo', outputFile, url])
6569
if (curl.error) throw curl.error
6670
}
6771

0 commit comments

Comments
 (0)