mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-09 12:52:20 +02:00
Handle download HTTP error (#511)
This commit is contained in:
parent
8bcd2560e2
commit
4818a5a153
3 changed files with 142 additions and 67 deletions
|
@ -72,15 +72,33 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
|||
const downloadUrl = release.files[0].download_url;
|
||||
|
||||
core.info(`Download from "${downloadUrl}"`);
|
||||
const pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
||||
core.info('Extract downloaded archive');
|
||||
let pythonExtractedFolder;
|
||||
if (IS_WINDOWS) {
|
||||
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
||||
} else {
|
||||
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
||||
}
|
||||
let pythonPath = '';
|
||||
try {
|
||||
pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
||||
core.info('Extract downloaded archive');
|
||||
let pythonExtractedFolder;
|
||||
if (IS_WINDOWS) {
|
||||
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
||||
} else {
|
||||
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
||||
}
|
||||
|
||||
core.info('Execute installation script');
|
||||
await installPython(pythonExtractedFolder);
|
||||
core.info('Execute installation script');
|
||||
await installPython(pythonExtractedFolder);
|
||||
} catch (err) {
|
||||
if (err instanceof tc.HTTPError) {
|
||||
// Rate limit?
|
||||
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
|
||||
core.info(
|
||||
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
||||
);
|
||||
} else {
|
||||
core.info(err.message);
|
||||
}
|
||||
if (err.stack) {
|
||||
core.debug(err.stack);
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue