Skip to content

Commit

Permalink
Merge pull request #15 from mikepenz/other/use_github_request_api
Browse files Browse the repository at this point in the history
Use GitHub dependency to upload file
  • Loading branch information
mikepenz committed Mar 14, 2024
2 parents e96723b + b167d3a commit 51db930
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ const upload = async (config, github, url, path, currentAssets) => {
const endpoint = new URL(url);
endpoint.searchParams.append('name', name);
try {
const resp = await fetch(endpoint, {
const resp = await github.request({
method: 'POST',
url: endpoint.toString(),
headers: {
'content-length': `${size}`,
'content-type': mime,
authorization: `token ${config.github_token}`
},
method: 'POST',
body
data: body
});
try {
const json = await resp.json();
const json = resp.data;
if (resp.status !== 201) {
throw new Error(`Failed to upload release asset ${name}. received status code ${resp.status}\n${json.message}\n${JSON.stringify(json.errors)}`);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,19 @@ export const upload = async (
const endpoint = new URL(url)
endpoint.searchParams.append('name', name)
try {
const resp = await fetch(endpoint, {
const resp = await github.request({
method: 'POST',
url: endpoint.toString(),
headers: {
'content-length': `${size}`,
'content-type': mime,
authorization: `token ${config.github_token}`
},
method: 'POST',
body
data: body
})

try {
const json = await resp.json()
const json = resp.data
if (resp.status !== 201) {
throw new Error(
`Failed to upload release asset ${name}. received status code ${resp.status}\n${json.message}\n${JSON.stringify(
Expand Down

0 comments on commit 51db930

Please sign in to comment.