From 7cac809eef6869c7487cd5c42e68919c975580ce Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Fri, 3 Jul 2020 06:59:57 +0200 Subject: [PATCH] Fix for new octokit --- dist/index.js | 11 +---------- src/main.ts | 11 +++-------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/dist/index.js b/dist/index.js index 930b8c3..061532e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2226,7 +2226,6 @@ function upload_to_release(release, file, asset_name, tag, overwrite, octokit) { core.debug(`Skipping ${file}, since its not a file`); return; } - const file_size = stat.size; const file_bytes = fs.readFileSync(file); // Check for duplicates. const assets = yield octokit.repos.listReleaseAssets(Object.assign(Object.assign({}, github.context.repo), { release_id: release.data.id })); @@ -2245,15 +2244,7 @@ function upload_to_release(release, file, asset_name, tag, overwrite, octokit) { core.debug(`No pre-existing asset called ${asset_name} found in release ${tag}. All good.`); } core.debug(`Uploading ${file} to ${asset_name} in release ${tag}.`); - yield octokit.repos.uploadReleaseAsset({ - url: release.data.upload_url, - name: asset_name, - file: file_bytes, - headers: { - 'content-type': 'binary/octet-stream', - 'content-length': file_size - } - }); + yield octokit.repos.uploadReleaseAsset(Object.assign(Object.assign({}, github.context.repo), { release_id: release.data.id, data: file_bytes })); }); } function run() { diff --git a/src/main.ts b/src/main.ts index 1bd3f87..002786d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -51,7 +51,6 @@ async function upload_to_release( core.debug(`Skipping ${file}, since its not a file`) return } - const file_size = stat.size const file_bytes = fs.readFileSync(file) // Check for duplicates. @@ -81,13 +80,9 @@ async function upload_to_release( core.debug(`Uploading ${file} to ${asset_name} in release ${tag}.`) await octokit.repos.uploadReleaseAsset({ - url: release.data.upload_url, - name: asset_name, - file: file_bytes, - headers: { - 'content-type': 'binary/octet-stream', - 'content-length': file_size - } + ...github.context.repo, + release_id: release.data.id, + data: file_bytes }) }