Skip to content

Commit

Permalink
Merge pull request #8 from gregoranders/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
gregoranders authored Apr 10, 2020
2 parents c53b794 + c7f6285 commit b4d9493
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@actions/github": "2.1.1"
},
"devDependencies": {
"@octokit/rest": "17.2.0",
"@types/jest": "25.2.1",
"@types/mime": "2.0.1",
"@zeit/ncc": "0.22.1",
Expand Down
12 changes: 4 additions & 8 deletions src/action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ describe("nodejs-upload-asset", () => {
process.env.GITHUB_TOKEN = "abcd";
uploadReleaseAssetMock.mockReturnValue({
data: {
value: {
browser_download_url: "download_url",
id: 1,
}
browser_download_url: "download_url",
id: 1,
},
});
return testSubject().then(() => {
Expand All @@ -62,10 +60,8 @@ describe("nodejs-upload-asset", () => {
process.env.GITHUB_TOKEN = "abcd";
uploadReleaseAssetMock.mockReturnValue({
data: {
value: {
browser_download_url: "download_url",
id: 1,
}
browser_download_url: "download_url",
id: 1,
},
});
return testSubject().then(() => {
Expand Down
16 changes: 8 additions & 8 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import * as fs from "fs";
import { getType } from "mime";
import { basename, resolve } from "path";

import Octokit from "@actions/github/node_modules/@octokit/rest";
import { Octokit } from "@octokit/rest";

type ReposUploadReleaseAssetParams = Octokit.Octokit.ReposUploadReleaseAssetParams;
type ReposUploadReleaseAssetParams = Octokit.ReposUploadReleaseAssetParams;

const uploadAsset = async (client: GitHub, params: ReposUploadReleaseAssetParams) => {
core.startGroup(`Uploading asset ${params.label} to release ${params.url}`);
const response = await client.repos.uploadReleaseAsset(params);
core.info(`Release asset ${response.data.value.name} created [id: ${response.data.value.id}]`);
core.startGroup(`Uploading asset ${params.name} to release ${params.url}`);
// tslint:disable-next-line: no-any
const response = await client.repos.uploadReleaseAsset(params) as any;
core.info(`Release asset ${response.data.name} created [id: ${response.data.id}]`);
core.endGroup();
return response.data.value;
return response.data;
};


const prepareHeaders = (fullPathChecked: string, mime: string) => {
return {
"content-length": fs.statSync(fullPathChecked).size,
Expand All @@ -26,7 +26,7 @@ const prepareHeaders = (fullPathChecked: string, mime: string) => {
};

const prepareParams = (data: Buffer, headers: { "content-length": number; "content-type": string; },
label: string, name: string, url: string): Octokit.Octokit.ReposUploadReleaseAssetParams => {
label: string, name: string, url: string): Octokit.ReposUploadReleaseAssetParams => {
return {
data,
headers,
Expand Down

0 comments on commit b4d9493

Please sign in to comment.