use matrix

This commit is contained in:
Laesse 2022-08-15 22:15:56 +02:00
parent ad093d0caa
commit 20c01510ee
2 changed files with 18 additions and 24 deletions

View file

@ -1,16 +1,14 @@
const child_process = require("child_process");
const child_process = require('child_process');
const services = ["bar-service", "foo-service"];
const services = ['bar-service', 'foo-service'];
function latestCommitInDirectory(dirname) {
return String(
child_process.execSync(`git log --pretty=format:%H -n 1 ${dirname}`)
);
return String(child_process.execSync(`git log --pretty=format:%H -n 1 ${dirname}`));
}
const serviceVersions = {};
const currentCommit = latestCommitInDirectory(".");
const currentCommit = latestCommitInDirectory('.');
for (const service of services) {
serviceVersions[service] = latestCommitInDirectory(service);
@ -19,8 +17,14 @@ for (const service of services) {
console.log(currentCommit);
console.log(serviceVersions);
let job_strategy_matrix = [];
Object.entries(serviceVersions).forEach(([name, version]) => {
const skip = version === currentCommit ? "run" : "skip";
const skip = version === currentCommit ? 'run' : 'skip';
console.log(`::set-output name=${name}::${skip}`);
console.log(`${name}::${skip}`);
if (version === currentCommit) {
job_strategy_matrix.push(name);
}
});
console.log(`::set-output name=job-strategy-matrix::[${job_strategy_matrix.join(', ')}]`);