mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-11 19:04:20 +00:00
format upload url
This commit is contained in:
parent
11282f4ee9
commit
d9cc08588c
4 changed files with 25 additions and 3 deletions
|
@ -4,11 +4,22 @@ import {
|
||||||
paths,
|
paths,
|
||||||
parseConfig,
|
parseConfig,
|
||||||
parseInputFiles,
|
parseInputFiles,
|
||||||
unmatchedPatterns
|
unmatchedPatterns,
|
||||||
|
uploadUrl
|
||||||
} from "../src/util";
|
} from "../src/util";
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
describe("util", () => {
|
describe("util", () => {
|
||||||
|
describe("uploadUrl", () => {
|
||||||
|
it("stripts template", () => {
|
||||||
|
assert.equal(
|
||||||
|
uploadUrl(
|
||||||
|
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}"
|
||||||
|
),
|
||||||
|
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe("parseInputFiles", () => {
|
describe("parseInputFiles", () => {
|
||||||
it("parses empty strings", () => {
|
it("parses empty strings", () => {
|
||||||
assert.deepStrictEqual(parseInputFiles(""), []);
|
assert.deepStrictEqual(parseInputFiles(""), []);
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -144,7 +144,10 @@ export const upload = async (
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body
|
body
|
||||||
});
|
});
|
||||||
return resp.json();
|
console.log(`resp`, resp);
|
||||||
|
const json = await resp.json();
|
||||||
|
console.log(`body`, json);
|
||||||
|
return json;
|
||||||
|
|
||||||
// return await gh.rest.repos.uploadReleaseAsset({
|
// return await gh.rest.repos.uploadReleaseAsset({
|
||||||
// url,
|
// url,
|
||||||
|
|
|
@ -18,6 +18,14 @@ export interface Config {
|
||||||
input_target_commitish?: string;
|
input_target_commitish?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const uploadUrl = (url: string): string => {
|
||||||
|
const templateMarkerPos = url.indexOf("{");
|
||||||
|
if (templateMarkerPos > -1) {
|
||||||
|
return url.substring(0, templateMarkerPos);
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
export const releaseBody = (config: Config): string | undefined => {
|
export const releaseBody = (config: Config): string | undefined => {
|
||||||
return (
|
return (
|
||||||
(config.input_body_path &&
|
(config.input_body_path &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue