Skip to content

Commit

Permalink
Merge pull request #13 from UlisesGascon/feat/optimizations
Browse files Browse the repository at this point in the history
Migrate to Github Actions HTTP client
  • Loading branch information
UlisesGascon authored Aug 21, 2023
2 parents de2ac17 + 1de1b5d commit 7713057
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1"
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.1.1"
}
}
18 changes: 4 additions & 14 deletions utils/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import exec from '@actions/exec'
import * as core from '@actions/core'
import { HttpClient } from '@actions/http-client'
import { readFileSync, writeFileSync } from 'node:fs'
import { readdir } from 'node:fs/promises'
import https from 'node:https'
import { join } from 'node:path'

const httpAgent = new HttpClient('node-dist-health')

export async function getAllResults () {
const resultsFolder = join(process.cwd(), 'results')
const files = await readdir(resultsFolder)
Expand Down Expand Up @@ -83,19 +85,7 @@ export function overwriteReleaseUrls (urls) {
}

function downloadFile (url) {
return new Promise((resolve, reject) => {
https.get(url, (resp) => {
let data = ''

resp.on('data', (chunk) => {
data += chunk
})

resp.on('end', () => {
resolve(data)
})
}).on('error', reject)
})
return httpAgent.get(url).then(res => res.readBody())
}

export async function downloadReleases () {
Expand Down

0 comments on commit 7713057

Please sign in to comment.