Skip to content

Commit 5385dde

Browse files
committed
do not rely on environment for matrix build
ENV didn't work correctly during scheduled jobs and this also allows to run the matrix script locally.
1 parent 2e99251 commit 5385dde

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

.github/matrix.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ function getVersions()
2222
/**
2323
* Get the last commit of a branch
2424
*
25+
* @param string $repo
2526
* @param string $branch
2627
* @return string
2728
*/
28-
function getLastCommit($branch)
29+
function getLastCommit($repo, $branch)
2930
{
3031
$opts = [
3132
'http' => [
@@ -38,7 +39,7 @@ function getLastCommit($branch)
3839
];
3940
$context = stream_context_create($opts);
4041

41-
$data = file_get_contents('https://api.github.com/repos/dokuwiki/dokuwiki/commits/' . $branch, false, $context);
42+
$data = file_get_contents("https://api.github.com/repos/dokuwiki/$repo/commits/$branch", false, $context);
4243
$json = json_decode($data, true);
4344
return $json['sha'];
4445
}
@@ -86,13 +87,13 @@ function getImageTag()
8687

8788

8889
$result = [];
89-
$self = $_ENV['GITHUB_SHA'] ?? 'unknown';
90+
$self = getLastCommit('docker', 'main');
9091
$upstreamTag = getImageTag();
9192
$image = getImageId($upstreamTag);
9293

9394
foreach (getVersions() as $release => $info) {
9495
$branch = $release === 'oldstable' ? 'old-stable' : $release;
95-
$commit = getLastCommit($branch);
96+
$commit = getLastCommit('dokuwiki', $branch);
9697
$ident = join('-', [$release, $commit, $image, $self]);
9798
$cache = '.github/matrix.cache/' . $release;
9899

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
.github/matrix.cache/
12
storage/

0 commit comments

Comments
 (0)