From 592950c6f00b2bb2a7b6afa794f13448818339f0 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Sat, 12 Jun 2021 23:42:37 +0200 Subject: [PATCH 1/3] Auto Fix PSR12 Style --- app/Http/Livewire/ConfiguratorForm.php | 19 ++++++++----------- resources/views/action_yaml.blade.php | 3 +++ .../views/livewire/form/deploy.blade.php | 16 ++++++++++++++-- tests/Feature/DeployTest.php | 11 +++++++++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/app/Http/Livewire/ConfiguratorForm.php b/app/Http/Livewire/ConfiguratorForm.php index cb3334b..4ab94be 100644 --- a/app/Http/Livewire/ConfiguratorForm.php +++ b/app/Http/Livewire/ConfiguratorForm.php @@ -4,6 +4,7 @@ use App\Models\Configuration; use App\Traits\Form\CodeQuality; +use App\Traits\Form\Deploy; use App\Traits\Form\LaravelStuff; use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException; use DanHarrin\LivewireRateLimiting\WithRateLimiting; @@ -27,6 +28,7 @@ class ConfiguratorForm extends Component use WithRateLimiting; use CodeQuality; use LaravelStuff; + use Deploy; public $code = ""; public $template = ""; @@ -66,9 +68,7 @@ class ConfiguratorForm extends Component public $stepCachePackages; //true public $stepCacheVendors; //true public $stepCacheNpmModules; // true - public $stepDeployType; - public $stepDeployWebhookType; - public $stepDeployWebhookUrl; + public $result; @@ -117,12 +117,11 @@ private function loadDefaults(): void $this->stepCachePackages = true; $this->stepCacheVendors = true; $this->stepCacheNpmModules = true; - $this->stepDeployType = 'none'; - $this->stepDeployWebhookType = 'secret'; - $this->stepDeployWebhookUrl = "WEBHOOK_URL"; + $this->loadDefaultsCodeQuality(); $this->loadDefaultsLaravelStuff(); + $this->loadDefaultsDeploy(); } private function loadFromJson($j): void @@ -181,6 +180,7 @@ private function loadFromJson($j): void $this->loadCodeQualityFromJson($j); $this->loadLaravelStuffFromJson($j); + $this->loadDeployFromJson($j); } public function mount(): void { @@ -334,14 +334,11 @@ public function submitForm() "stepNodejsVersion", "stepCachePackages", "stepCacheVendors", - "stepCacheNpmModules", - "stepDeployType", - "stepDeployWebhookType", - "stepDeployWebhookUrl" + "stepCacheNpmModules" ); $data = $this->setDataCodeQuality($data); $data = $this->setDataLaravelStuff($data); - + $data = $this->setDeployData($data); $data["stepPhpVersionsString"] = self::arrayToString($this->stepPhpVersions); $data["on_pullrequest_branches"] = self::split($this->onPullrequestBranches); $data["on_push_branches"] = self::split($this->onPushBranches); diff --git a/resources/views/action_yaml.blade.php b/resources/views/action_yaml.blade.php index 183e568..f7fa649 100644 --- a/resources/views/action_yaml.blade.php +++ b/resources/views/action_yaml.blade.php @@ -117,3 +117,6 @@ @if ($stepDeployType === "ploi") @include('yaml.deploy_ploi') @endif +@if ($stepDeployType === "vapor") + @include('yaml.deploy_vapor') +@endif diff --git a/resources/views/livewire/form/deploy.blade.php b/resources/views/livewire/form/deploy.blade.php index 00b65de..3fe76e3 100644 --- a/resources/views/livewire/form/deploy.blade.php +++ b/resources/views/livewire/form/deploy.blade.php @@ -1,6 +1,8 @@ -
+
Deployment (Experimental feature) - +
@@ -16,5 +18,15 @@
+
+
+ +
+ + You need to set a GitHub Secret in settings/secrets/actions/new named VAPOR_API_TOKEN. + Take a look the documentation about Vapor Laravel Vapor, Deploying From CI +
+
+
diff --git a/tests/Feature/DeployTest.php b/tests/Feature/DeployTest.php index ec719f7..c2b00a4 100644 --- a/tests/Feature/DeployTest.php +++ b/tests/Feature/DeployTest.php @@ -23,6 +23,17 @@ public function testPloiDeploy() ->set("stepDeployWebhookType","secret") ->call('submitForm') ->assertSee(file_get_contents(base_path(self::DIR_MOCK."ploi-deploy.yaml"))); + + } + public function testVaporDeploy() + { + Livewire::test(ConfiguratorForm::class) + ->set("name","Test") + ->set("stepDeployType","vapor") + + ->call('submitForm') + ->assertSee(file_get_contents(base_path(self::DIR_MOCK."vapor-deploy.yaml"))); + } } From 8c02f21d418fe868e6dcf14b2bc0c0cd4fa44fe2 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Sat, 12 Jun 2021 23:46:18 +0200 Subject: [PATCH 2/3] Vapor Deploy --- app/Traits/Form/Deploy.php | 42 +++++++++++++++++++ .../views/livewire/form/deploy.blade.php | 2 +- resources/views/yaml/deploy_vapor.blade.php | 7 ++++ tests/Feature/mock-asserts/vapor-deploy.yaml | 6 +++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 app/Traits/Form/Deploy.php create mode 100644 resources/views/yaml/deploy_vapor.blade.php create mode 100644 tests/Feature/mock-asserts/vapor-deploy.yaml diff --git a/app/Traits/Form/Deploy.php b/app/Traits/Form/Deploy.php new file mode 100644 index 0000000..d18118a --- /dev/null +++ b/app/Traits/Form/Deploy.php @@ -0,0 +1,42 @@ +stepDeployType = 'none'; + $this->stepDeployWebhookType = 'secret'; + $this->stepDeployWebhookUrl = "WEBHOOK_URL"; + //$this->stepDeployApiToken = "VAPOR_API_TOKEN"; + } + + public function loadDeployFromJson($j): void + { + data_fill($j, "stepDeployType", 'none'); + data_fill($j, "stepDeployWebhookType", 'secret'); + data_fill($j, "stepDeployWebhookUrl", 'WEBHOOK_URL'); + //data_fill($j, "stepDeployApiToken", 'VAPOR_API_TOKEN'); + + $this->stepDeployType = $j->stepDeployType; + $this->stepDeployWebhookType = $j->stepDeployWebhookType; + $this->stepDeployWebhookUrl = $j->stepDeployWebhookUrl; + //$this->stepDeployApiToken = $j->stepDeployApiToken; + } + + public function setDeployData($data) + { + $data["stepDeployType"] = $this->stepDeployType; + $data["stepDeployWebhookType"] = $this->stepDeployWebhookType; + $data["stepDeployWebhookUrl"] = $this->stepDeployWebhookUrl; + //$data["stepDeployApiToken"] = $this->stepDeployApiToken; + + return $data; + } +} diff --git a/resources/views/livewire/form/deploy.blade.php b/resources/views/livewire/form/deploy.blade.php index 3fe76e3..1395214 100644 --- a/resources/views/livewire/form/deploy.blade.php +++ b/resources/views/livewire/form/deploy.blade.php @@ -24,7 +24,7 @@
You need to set a GitHub Secret in settings/secrets/actions/new named VAPOR_API_TOKEN. - Take a look the documentation about Vapor Laravel Vapor, Deploying From CI + Take a look the documentation about Laravel Vapor, Deploying From CI
diff --git a/resources/views/yaml/deploy_vapor.blade.php b/resources/views/yaml/deploy_vapor.blade.php new file mode 100644 index 0000000..35a0e92 --- /dev/null +++ b/resources/views/yaml/deploy_vapor.blade.php @@ -0,0 +1,7 @@ +# Deployment Step + - name: Require Vapor CLI + run: composer global require laravel/vapor-cli + - name: Deploy Environment + run: vapor deploy + env: + VAPOR_API_TOKEN: $@{{ secrets.VAPOR_API_TOKEN }} diff --git a/tests/Feature/mock-asserts/vapor-deploy.yaml b/tests/Feature/mock-asserts/vapor-deploy.yaml new file mode 100644 index 0000000..e68a24a --- /dev/null +++ b/tests/Feature/mock-asserts/vapor-deploy.yaml @@ -0,0 +1,6 @@ + - name: Require Vapor CLI + run: composer global require laravel/vapor-cli + - name: Deploy Environment + run: vapor deploy + env: + VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} From 8bb3394752d24a5634d347c793417b4ee1bc12a2 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Sat, 12 Jun 2021 23:49:50 +0200 Subject: [PATCH 3/3] v0.3.6 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d473825..a1f8b07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## 0.3.6 - 2021-06-13 + +### Add +- Deploy Serverless Application via Vapor ## 0.3.5 - 2021-05-17