Skip to content

Commit

Permalink
Update MatrixCommand.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Sep 8, 2023
1 parent 12a8e14 commit ce1a350
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Command/MatrixCommand.php
Expand Up @@ -6,7 +6,6 @@

use Ghostwriter\Compliance\Compliance;
use Ghostwriter\Compliance\Event\MatrixEvent;
use Ghostwriter\Environment\Environment;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -36,11 +35,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
new MatrixEvent($input, $this->symfonyStyle)
);

$environment = new Environment();
$gitHubOutput = getenv('GITHUB_OUTPUT')?: tempnam(sys_get_temp_dir(), 'GITHUB_OUTPUT');

if (! is_string($gitHubOutput)) {
$this->write('GITHUB_OUTPUT environment variable not set.');

return self::FAILURE;
}

$matrix = sprintf('matrix=%s' . PHP_EOL, $matrixEvent->getMatrix());

file_put_contents(
$environment->getServerVariable('GITHUB_OUTPUT', tempnam(sys_get_temp_dir(), 'GITHUB_OUTPUT')),
$gitHubOutput,
$matrix,
FILE_APPEND
);
Expand Down

0 comments on commit ce1a350

Please sign in to comment.