Refactor to use setup-php

This commit is contained in:
Shivam Mathur
2021-09-19 06:06:31 +05:30
parent 3572ca5db9
commit b52930e590
7 changed files with 2811 additions and 2074 deletions

View File

@@ -1,6 +1,7 @@
import {exec} from '@actions/exec';
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as spu from 'setup-php/lib/utils';
import * as path from 'path';
import * as utils from './utils';
@@ -17,7 +18,7 @@ export async function handleDependencies(
if (!/^5.[3-5]$/.test(version) && /linux|darwin/.test(process.platform)) {
const cache_key: string = (await utils.getOutput('key')) + '-deps';
const cache_dir: string = path.join(
await utils.readEnv('RUNNER_TOOL_CACHE'),
await spu.readEnv('RUNNER_TOOL_CACHE'),
'deps'
);
const cache_hit: string | undefined = await cache.restoreCache(
@@ -37,17 +38,17 @@ export async function handleDependencies(
*/
export async function run(): Promise<void> {
try {
const version: string = await utils.parseVersion(
await utils.getInput('php-version', true)
const version: string = await spu.parseVersion(
await spu.getInput('php-version', true)
);
const extensions: string = await utils.filterExtensions(
await utils.getInput('extensions', true)
await spu.getInput('extensions', true)
);
const key: string = await utils.getInput('key', true);
const key: string = await spu.getInput('key', true);
await exec(await utils.scriptCall('data', extensions, version, key));
await handleDependencies(extensions, version);
} catch (error) {
core.setFailed(error.message);
core.setFailed((error as Error).message);
}
}