Skip to content

Commit c5c25e9

Browse files
authored
Merge branch 'main' into fix/delete-old-action-files
2 parents 7d3b07d + 8edfc6a commit c5c25e9

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/Adapter/Docker/Configuration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public function getConfigTreeBuilder(): TreeBuilder
2121
->arrayNode('tags')
2222
->scalarPrototype()->end()
2323
->end()
24+
->arrayNode('copy')
25+
->arrayPrototype()
26+
->children()
27+
->scalarNode('from')->isRequired()->end()
28+
->scalarNode('to')->isRequired()->end()
29+
->end()
30+
->end()
31+
->end()
2432
->end()
2533
;
2634

src/Adapter/Docker/Factory.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,16 @@ public function __invoke(array $configuration): Configurator\SatelliteBuilderInt
3232
if (isset($configuration['docker']['tags'])) {
3333
$builder->withTags(...$configuration['docker']['tags']);
3434
}
35-
36-
if (isset($configuration['docker']['include']) && is_iterable($configuration['docker']['include'])) {
37-
foreach ($configuration['docker']['include'] as $path) {
38-
if (is_dir($path)) {
39-
$builder->withDirectory(new Packaging\Directory($path));
40-
} else {
41-
$builder->withFile(new Packaging\Asset\LocalFile($path));
35+
if (isset($configuration['docker']['copy'])) {
36+
foreach ($configuration['docker']['copy'] as $copy) {
37+
if (!file_exists($copy['from'])) {
38+
throw new FileOrDirectoryNotFoundException(strtr('Unable to find the file or the directory at path %path%', ['path' => $copy['from']]));
4239
}
43-
}
44-
}
4540

46-
if (isset($configuration['include'])) {
47-
foreach ($configuration['include'] as $path) {
48-
if (is_dir($path)) {
49-
$builder->withDirectory(new Packaging\Directory($path));
41+
if (is_file($copy['from'])) {
42+
$builder->withFile(new Packaging\File($copy['from'], new Packaging\Asset\LocalFile($copy['from'])), $copy['to']);
5043
} else {
51-
$builder->withFile(new Packaging\Asset\LocalFile($path));
44+
$builder->withDirectory(new Packaging\Directory($copy['from']), $copy['to']);
5245
}
5346
}
5447
}
@@ -60,6 +53,9 @@ public function __invoke(array $configuration): Configurator\SatelliteBuilderInt
6053
} else {
6154
$builder->withComposerFile(new Packaging\Asset\LocalFile('composer.json'));
6255
}
56+
if (file_exists('vendor')) {
57+
$builder->withDirectory(new Packaging\Directory('vendor/'));
58+
}
6359
}
6460

6561
if (\array_key_exists('autoload', $configuration['composer']) && \array_key_exists('psr4', $configuration['composer']['autoload'])) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Satellite\Adapter\Docker;
6+
7+
class FileOrDirectoryNotFoundException extends \RuntimeException {}

src/Adapter/Docker/Satellite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function dependsOn(string ...$dependencies): self
5656
public function build(
5757
LoggerInterface $logger,
5858
): void {
59-
$archive = new TarArchive($this->dockerfile, ...$this->files);
59+
$archive = new TarArchive($this->dockerfile, ...array_values($this->files));
6060

6161
$iterator = function (iterable $tags) {
6262
foreach ($tags as $tag) {

0 commit comments

Comments
 (0)