Skip to content

Commit

Permalink
Merge pull request #21 from depot/error-handling
Browse files Browse the repository at this point in the history
If releases API returns an error, surface in Actions
  • Loading branch information
jsierles authored Mar 24, 2022
2 parents 7fc512c + 1c4367e commit 1895905
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions setup-flyctl/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ async function resolveVersion(version: string) {
const os = process.platform
const arch = process.arch === 'x64' ? 'amd64' : process.arch
const res = await client.get(`https://api.fly.io/app/flyctl_releases/${os}/${arch}/${version}`)
const url = await res.readBody()
const matches = url.match(/superfly\/flyctl\/releases\/download\/v(\d+\.\d+\.\d+)/)
const body = await res.readBody()
if (!res.message.statusCode || res.message.statusCode >= 400) throw new Error(body)
const matches = body.match(/superfly\/flyctl\/releases\/download\/v(\d+\.\d+\.\d+)/)
const resolvedVersion = matches ? matches[1] : version
return {url, resolvedVersion}
return {url: body, resolvedVersion}
}

async function installFlyctl(url: string, resolvedVersion: string) {
Expand Down

0 comments on commit 1895905

Please sign in to comment.