Reuse manifest code

This commit is contained in:
Gordey Doronin 2021-06-22 17:52:06 +02:00
parent d9ce83b637
commit c2dfe2df98
3 changed files with 29 additions and 37 deletions

View file

@ -42,14 +42,10 @@ export async function getNode(
if (isLtsAlias(versionSpec)) {
core.info('Attempt to resolve LTS alias from manifest...');
core.debug('Getting manifest from actions/node-versions@main');
// No try-catch since it's not possible to resolve LTS alias without manifest
manifest = await tc.getManifestFromRepo(
'actions',
'node-versions',
auth,
'main'
);
manifest = await getManifest(auth);
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
}
@ -200,6 +196,11 @@ function isLtsAlias(versionSpec: string): boolean {
return versionSpec.startsWith('lts');
}
function getManifest(auth: string | undefined): Promise<tc.IToolRelease[]> {
core.debug('Getting manifest from actions/node-versions@main');
return tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
}
function resolveLtsAliasFromManifest(
versionSpec: string,
stable: boolean,
@ -245,16 +246,8 @@ async function getInfoFromManifest(
): Promise<INodeVersionInfo | null> {
let info: INodeVersionInfo | null = null;
if (!manifest) {
core.debug(
'No manifest cached, getting manifest from actions/node-versions@main'
);
manifest = await tc.getManifestFromRepo(
'actions',
'node-versions',
auth,
'main'
);
core.debug('No manifest cached');
manifest = await getManifest(auth);
}
const rel = await tc.findFromManifest(versionSpec, stable, manifest, osArch);