Skip to content

Commit

Permalink
Merge pull request #84 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.3.6
  • Loading branch information
roberto-butti authored Jun 12, 2021
2 parents 39e6128 + 1d49e8d commit c12b4df
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## 0.3.6 - 2021-06-13

### Add
- Deploy Serverless Application via Vapor

## 0.3.5 - 2021-05-17

Expand Down
19 changes: 8 additions & 11 deletions app/Http/Livewire/ConfiguratorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@ class ConfiguratorForm extends Component
use WithRateLimiting;
use CodeQuality;
use LaravelStuff;
use Deploy;

public $code = "";
public $template = "";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -181,6 +180,7 @@ private function loadFromJson($j): void

$this->loadCodeQualityFromJson($j);
$this->loadLaravelStuffFromJson($j);
$this->loadDeployFromJson($j);
}
public function mount(): void
{
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 42 additions & 0 deletions app/Traits/Form/Deploy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Traits\Form;

trait Deploy
{
public $stepDeployType;
public $stepDeployWebhookType;
public $stepDeployWebhookUrl;
//public $stepDeployApiToken;

public function loadDefaultsDeploy(): void
{
$this->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;
}
}
3 changes: 3 additions & 0 deletions resources/views/action_yaml.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,6 @@
@if ($stepDeployType === "ploi")
@include('yaml.deploy_ploi')
@endif
@if ($stepDeployType === "vapor")
@include('yaml.deploy_vapor')
@endif
16 changes: 14 additions & 2 deletions resources/views/livewire/form/deploy.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<fieldset class="border-2 border-blue-200 shadow-xl p-4 rounded-xl" x-data="{ showPloiService: {{ $stepDeployType === 'ploi' ? 'true' : 'false' }}}">
<fieldset class="border-2 border-blue-200 shadow-xl p-4 rounded-xl" x-data="{ showPloiService: {{ $stepDeployType === 'ploi'? 'true' : 'false' }},
showVaporService: {{ $stepDeployType === 'vapor'? 'true' : 'false' }}
}">
<legend class="text-xl font-medium text-gray-900 px-2 pb-2">Deployment (Experimental feature)</legend>
<x-form.input-select model="stepDeployType" name="stepDeployType" label="Select Deployment Step" :list="['none'=>'None', 'ploi'=>'Ploi']" help="Deployment: *None* if you don't want to deploy the code in your workflow. Otherwise select from available options" multiselect=0 onChange='showPloiService= $event.target.value==="ploi";'>
<x-form.input-select model="stepDeployType" name="stepDeployType" label="Select Deployment Step" :list="['none'=>'None', 'ploi'=>'Ploi', 'vapor' => 'Vapor']" help="Deployment: *None* if you don't want to deploy the code in your workflow. Otherwise select from available options" multiselect=0 onChange='showPloiService= $event.target.value==="ploi";'>
</x-form.input-select>

<div x-show="showPloiService">
Expand All @@ -16,5 +18,15 @@
</div>
</div>
</div>
<div x-show="showVaporService">
<div class="md:grid md:grid-cols-3 md:gap-3">

<div class="col-span-3">

You need to set a GitHub Secret in settings/secrets/actions/new named VAPOR_API_TOKEN.
Take a look the documentation about <a href="https://docs.vapor.build/1.0/projects/deployments.html#deploying-from-ci">Laravel Vapor, Deploying From CI</a>
</div>
</div>
</div>

</fieldset>
7 changes: 7 additions & 0 deletions resources/views/yaml/deploy_vapor.blade.php
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 11 additions & 0 deletions tests/Feature/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")));

}

}
6 changes: 6 additions & 0 deletions tests/Feature/mock-asserts/vapor-deploy.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit c12b4df

Please sign in to comment.