forked from dapr/php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-examples.php
More file actions
29 lines (26 loc) · 816 Bytes
/
update-examples.php
File metadata and controls
29 lines (26 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$examples = [
'actor',
'secrets',
'laravel'
];
$branch = getenv('GIT_BRANCH') ?: trim(`git rev-parse --abbrev-ref HEAD`);
$sha = getenv('GIT_SHA') ?: '';
foreach ($examples as $example) {
$composer = json_decode(file_get_contents("examples/$example/composer.json"));
$php_sdk = $composer?->require?->{'dapr/php-sdk'};
if ($php_sdk === null) {
continue;
}
if (!empty($sha)) {
$sha = "#$sha";
}
$composer->require->{'dapr/php-sdk'} = "dev-$branch$sha";
file_put_contents(
"examples/$example/composer.json",
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS) . "\n"
);
chdir("examples/$example");
echo `composer update`;
chdir(__DIR__);
}