Skip to content

Commit 1769a32

Browse files
committed
Optimize workflows for split repositories (#5)
1 parent b0eff15 commit 1769a32

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

.github/workflows/split.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- id: set-packages
1919
name: Generate Packages
20-
run: echo "packages=$(php tools/get-packages.php | jq -c)" >> $GITHUB_OUTPUT
20+
run: echo "packages=$(php tools/get-modified-packages.php | jq -c)" >> $GITHUB_OUTPUT
2121

2222
split:
2323
needs: generate-packages

tools/get-modified-packages.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of the aether/aether.
5+
*
6+
* Copyright (C) 2024 Dominik Szamburski
7+
*
8+
* This software may be modified and distributed under the terms
9+
* of the MIT license. See the LICENSE file for details.
10+
*/
11+
12+
$packages = \explode(PHP_EOL, \trim(\shell_exec("git diff HEAD --name-only packages/") ?? ''));
13+
$modifiedPackages = [];
14+
15+
foreach($packages as $package) {
16+
$directory = \explode(DIRECTORY_SEPARATOR, $package)[1] ?? '';
17+
if (empty($directory)) {
18+
continue;
19+
}
20+
21+
$composerFile = \dirname(__DIR__) . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . $directory . DIRECTORY_SEPARATOR . 'composer.json';
22+
$composerData = \json_decode(\file_get_contents($composerFile));
23+
24+
if (!$composerData->name) {
25+
continue;
26+
}
27+
28+
$modifiedPackages[$composerData->name] = [
29+
'name' => $composerData->name,
30+
'repository_name' => \str_replace('/', '-', $composerData->name),
31+
'package_directory' => $directory,
32+
];
33+
}
34+
35+
$output = [];
36+
$output['include'] = $modifiedPackages;
37+
38+
echo \json_encode($output);

0 commit comments

Comments
 (0)