Compare commits
2 Commits
22da85872d
...
d9bf86598b
| Author | SHA1 | Date | |
|---|---|---|---|
| d9bf86598b | |||
| 4388a7ec93 |
@@ -0,0 +1,51 @@
|
|||||||
|
name: Build and Deploy Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- masterApi
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.rhost.ovh
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./services/www/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: git.rhost.ovh/${{ github.repository }}:latest
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Deploy via SSH
|
||||||
|
uses: appleboy/ssh-action@v1.2.0
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
port: ${{ secrets.SERVER_PORT }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SERVER_SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
cd /home/ryjek/docker/sprawozdania
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
|
docker compose exec --workdir /var/www/html www APP_RUNTIME_ENV=prod php bin/console secrets:decrypt-to-local --force
|
||||||
|
docker compose exec --workdir /var/www/html www php ./bin/console doctrine:migration:migrate --dry-run
|
||||||
|
docker compose exec --workdir /var/www/html www php ./bin/console cache:clear
|
||||||
@@ -38,16 +38,6 @@ services:
|
|||||||
- internal
|
- internal
|
||||||
volumes:
|
volumes:
|
||||||
- ./storage/redis:/data
|
- ./storage/redis:/data
|
||||||
|
|
||||||
# wait_for_it:
|
|
||||||
# build:
|
|
||||||
# context: .
|
|
||||||
# dockerfile: services/wait_for_it/Dockerfile
|
|
||||||
# networks:
|
|
||||||
# - internal
|
|
||||||
# depends_on:
|
|
||||||
# - database
|
|
||||||
# command: sh -c "/wait -t 30 database:5432 -- echo 123;"
|
|
||||||
networks:
|
networks:
|
||||||
internal:
|
internal:
|
||||||
internal: true
|
internal: true
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace App\Controller\Api;
|
|||||||
|
|
||||||
use App\Entity\Clients;
|
use App\Entity\Clients;
|
||||||
use App\Repository\ClientsRepository;
|
use App\Repository\ClientsRepository;
|
||||||
|
use App\Services\AddReports;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
@@ -40,9 +41,45 @@ class ClientsController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/add', name: 'add_client', methods: ['POST'])]
|
#[Route('/add', name: 'add_client', methods: ['POST'])]
|
||||||
public function add(Request $request, EntityManagerInterface $entityManager): JsonResponse
|
public function add(Request $request, EntityManagerInterface $entityManager, AddReports $addReports): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->json($request->toArray(), context: ['groups' => ['client:add', 'client:read']]);
|
$need = [
|
||||||
|
"strName" => $request->getPayload()->get('name'),
|
||||||
|
"strAddress" => $request->getPayload()->get('address'),
|
||||||
|
"dateLegitimacy" => $request->getPayload()->get('legitimacy'),
|
||||||
|
"dateProclamation" => $request->getPayload()->get('proclamation'),
|
||||||
|
"intNIP" => $request->getPayload()->get('nip'),
|
||||||
|
"intPhone" => $request->getPayload()->get('phone'),
|
||||||
|
"strEmail" => $request->getPayload()->get('email'),
|
||||||
|
];
|
||||||
|
$newClient = new Clients();
|
||||||
|
foreach ($need as $key => $value) {
|
||||||
|
$cleared = $this->clearType($key, $value);
|
||||||
|
$method = 'set'.ucfirst($key);
|
||||||
|
$newClient->{$method}($cleared);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$entityManager->persist($newClient);
|
||||||
|
$entityManager->flush();
|
||||||
|
$entityManager->getCache()->evictEntityRegion(Clients::class);
|
||||||
|
$addReports->setClient($newClient);
|
||||||
|
$addReports->init();
|
||||||
|
|
||||||
|
return $this->json(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clearType(string $key, mixed $value)
|
||||||
|
{
|
||||||
|
if (str_contains($key, 'str')) {
|
||||||
|
return addslashes($value);
|
||||||
|
}
|
||||||
|
if (str_contains($key, 'int')) {
|
||||||
|
return intval($value);
|
||||||
|
}
|
||||||
|
if (str_contains($key, 'date')) {
|
||||||
|
return new \DateTime($value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[Route('/{id}', name: 'show', methods: ['GET'])]
|
// #[Route('/{id}', name: 'show', methods: ['GET'])]
|
||||||
|
|||||||
Reference in New Issue
Block a user