Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Handle API status correctly (fixes: https://github.com/GeopJr/action-…
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Sep 22, 2020
1 parent e39bcba commit cc74861
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
42 changes: 30 additions & 12 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function saveBuffer(input) {
await fs.appendFile('tts.wav', input);
} catch (err) {
core.setFailed('[ERROR]:' + err.message);
success = false;
return process.exit(1);
}
return success;
}
Expand All @@ -64,7 +64,7 @@ async function saveImage(input) {
}));
} catch (err) {
core.setFailed('[ERROR]:' + err.message);
success = false;
return process.exit(1);
}
return success;
}
Expand All @@ -74,10 +74,15 @@ async function getServer() {
try {
const response = await fetch(url)
const json = await response.json()
return json.status === "ok" ? `https://${json.data.server}.gofile.io/uploadFile` : false;
if(json.status === "ok") {
return `https://${json.data.server}.gofile.io/uploadFile`
} else {
core.setFailed('[ERROR]: GoFile returned ' + json.status);
return process.exit(1);
}
} catch (err) {
core.setFailed('[ERROR]:' + err.message);
return false
return process.exit(1);
}
}

Expand All @@ -96,10 +101,15 @@ async function upload(file, filename, url) {
body: form
})
const json = await response.json()
return json.status === "ok" ? `https://gofile.io/d/${json.data.code}` : false;
if(json.status === "ok") {
return `https://gofile.io/d/${json.data.code}`
} else {
core.setFailed('[ERROR]: GoFile returned ' + json.status);
return process.exit(1);
}
} catch (err) {
core.setFailed('[ERROR]:' + err.message);
return false
return process.exit(1);
}
}

Expand Down Expand Up @@ -135,8 +145,9 @@ async function run() {

tts = await speak(text)
await saveImage(text)
const audioUrl = await upload("tts.wav", "tts.wav", await getServer());
const imageUrl = await upload("image.jpg", "image.jpg", await getServer())
const url = await getServer();
const audioUrl = await upload("tts.wav", "tts.wav", url);
const imageUrl = await upload("image.jpg", "image.jpg", url)
const replyBody = "Accessibility Links:\nAudio Link:" + audioUrl + "\nImage Link:" + imageUrl
await octokit.issues.createComment({
owner: github.context.payload.repository.owner.login,
Expand Down

0 comments on commit cc74861

Please sign in to comment.