Skip to content

Commit

Permalink
Update action outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
socheatsok78 committed Jun 1, 2024
1 parent 06de8b5 commit c593063
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ async function main() {
? `Searching for "${inputs.search}" from "${source.repo}@${source.branch}"...`
: `Searching for "${inputs.search}" released in "${inputs.date}" from "${source.repo}@${source.branch}"...`
)
const data = await fetch(`https://raw.githubusercontent.com/${source.repo}/${source.branch}/releases/${inputs.search}.json`).then(res => res.json())
const url = `https://raw.githubusercontent.com/${source.repo}/${source.branch}/releases/${inputs.search}.json`
const data = await fetch(url).then(res => res.json())

// Filter by date
if (inputs.date) {
Expand Down Expand Up @@ -90,11 +91,24 @@ async function main() {
}

// Set outputs matrix
core.info("Result:")
core.info("----------------------------------------")
core.info(JSON.stringify(matrix))
core.info("----------------------------------------")
core.setOutput("matrix", JSON.stringify(matrix));
if (matrix.releases.length && matrix.versions.length) {
core.info("Result:")
core.info("----------------------------------------")
core.info(JSON.stringify(matrix))
core.info("----------------------------------------")
core.setOutput("matrix", JSON.stringify(matrix));
if (matrix.releases.length) {
core.setOutput("releases", JSON.stringify(matrix.releases));
}
if (matrix.versions.length) {
core.setOutput("versions", JSON.stringify(matrix.versions));
}
} else {
core.error([
"No result found for the given query, please check the input values or the source data.",
`Visit ${url} to check the source data.`,
].join("\n"))
}
}

main()

0 comments on commit c593063

Please sign in to comment.