1
0
Files
build-push-action/setup-qemu/src/main.ts
T

36 lines
1012 B
TypeScript
Raw Normal View History

2020-08-07 11:05:37 +02:00
import * as os from 'os';
import * as core from '@actions/core';
2020-08-12 01:48:35 +02:00
import * as exec from './exec';
interface Platforms {
supported: string[];
available: string[];
}
2020-08-07 11:05:37 +02:00
async function run(): Promise<void> {
try {
if (os.platform() !== 'linux') {
core.setFailed('Only supported on linux platform');
return;
}
2020-08-11 21:49:46 +02:00
const image: string = core.getInput('image') || 'tonistiigi/binfmt:latest';
const platforms: string = core.getInput('platforms') || 'all';
2020-08-07 11:05:37 +02:00
core.info(`💎 Installing QEMU static binaries...`);
2020-08-12 01:48:35 +02:00
await exec.exec(`docker`, ['run', '--rm', '--privileged', image, '--install', platforms], false).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
core.info('🛒 Extracting available platforms...');
const platforms: Platforms = JSON.parse(res.stdout.trim());
core.setOutput('platforms', platforms.supported.join(','));
});
2020-08-07 11:05:37 +02:00
} catch (error) {
core.setFailed(error.message);
}
}
run();