Define a helper to download to avoid duplication

This commit is contained in:
Benoit Daloze
2026-01-07 22:23:14 +01:00
parent 1010da45f3
commit d5f787ce33
4 changed files with 21 additions and 24 deletions
+1 -3
View File
@@ -4,7 +4,6 @@ const path = require('path')
const core = require('@actions/core')
const exec = require('@actions/exec')
const io = require('@actions/io')
const tc = require('@actions/tool-cache')
const common = require('./common')
const rubyBuilderVersions = require('./ruby-builder-versions')
@@ -74,9 +73,8 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) {
const downloadPath = await common.measure('Downloading Ruby', async () => {
const url = getDownloadURL(platform, engine, version)
console.log(url)
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
try {
return await tc.downloadTool(url, undefined, auth)
return await common.download(url)
} catch (error) {
if (error.message.includes('404')) {
throw new Error(`Unavailable version ${version} for ${engine} on ${platform}