1
0
mirror of https://github.com/shivammathur/setup-php.git synced 2025-04-10 21:24:17 +07:00

67 lines
2.1 KiB
TypeScript
Raw Normal View History

import path from 'path';
import fs from 'fs';
2021-03-03 10:28:50 +05:30
import {exec} from '@actions/exec';
2019-09-20 08:11:20 +05:30
import * as core from '@actions/core';
2019-10-08 18:12:54 +05:30
import * as config from './config';
import * as coverage from './coverage';
2019-10-27 05:42:49 +05:30
import * as extensions from './extensions';
2019-12-27 06:56:49 +05:30
import * as tools from './tools';
2019-10-27 05:42:49 +05:30
import * as utils from './utils';
2019-09-06 05:17:43 +05:30
2019-10-17 01:41:13 +05:30
/**
* Build the script
*
2022-01-29 05:29:58 +05:30
* @param os
2019-10-17 01:41:13 +05:30
*/
export async function getScript(os: string): Promise<string> {
2022-03-22 17:33:49 +05:30
const url = 'https://setup-php.com/support-ukraine';
const filename = os + (await utils.scriptExtension(os));
const script_path = path.join(__dirname, '../src/scripts', filename);
const run_path = script_path.replace(os, 'run');
2020-11-08 13:06:21 +05:30
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
2020-10-04 17:03:02 +05:30
const extension_csv: string = await utils.getInput('extensions', false);
2020-02-17 02:35:18 +05:30
const ini_values_csv: string = await utils.getInput('ini-values', false);
2019-11-24 02:04:12 +05:30
const coverage_driver: string = await utils.getInput('coverage', false);
2020-12-17 12:13:39 +05:30
const tools_csv: string = await utils.getInput('tools', false);
const version: string = await utils.parseVersion(
await utils.getInput('php-version', true)
);
const ini_file: string = await utils.parseIniFile(
await utils.getInput('ini-file', false)
);
let script = await utils.joins('.', script_path, version, ini_file);
2019-10-17 01:41:13 +05:30
if (extension_csv) {
2022-01-29 05:29:58 +05:30
script += await extensions.addExtension(extension_csv, version, os);
2019-10-17 01:41:13 +05:30
}
2022-01-29 05:29:58 +05:30
script += await tools.addTools(tools_csv, version, os);
2019-10-17 01:41:13 +05:30
if (coverage_driver) {
2022-01-29 05:29:58 +05:30
script += await coverage.addCoverage(coverage_driver, version, os);
2019-10-17 01:41:13 +05:30
}
2020-07-08 07:45:11 +05:30
if (ini_values_csv) {
2022-01-29 05:29:58 +05:30
script += await config.addINIValues(ini_values_csv, os);
2020-07-08 07:45:11 +05:30
}
2022-03-22 17:33:49 +05:30
script += '\n' + (await utils.stepLog(`#StandWithUkraine`, os));
script += '\n' + (await utils.addLog('$tick', 'read-more', url, os));
2020-09-07 01:43:15 +05:30
fs.writeFileSync(run_path, script, {mode: 0o755});
return run_path;
2019-10-17 01:41:13 +05:30
}
2019-09-20 08:11:20 +05:30
/**
* Run the script
*/
2019-11-24 02:04:12 +05:30
export async function run(): Promise<void> {
const os: string = process.platform;
const tool = await utils.scriptTool(os);
const run_path = await getScript(os);
await exec(tool + run_path);
2019-09-06 05:17:43 +05:30
}
2019-09-07 18:01:50 +05:30
// call the run function
2021-03-03 10:28:50 +05:30
(async () => {
await run();
})().catch(error => {
core.setFailed(error.message);
});