Compare commits

..

13 Commits

Author SHA1 Message Date
41547d6034 Atualizar .gitea/workflows/build.yaml
All checks were successful
Build e Deploy / build-and-deploy (push) Successful in 10m14s
2026-02-26 23:49:32 +00:00
48eab18fc8 Atualizar .gitea/workflows/build.yaml
Some checks failed
Build e Deploy Direto / build-and-deploy (push) Has been cancelled
2026-02-26 23:47:37 +00:00
0989b162f6 Atualizar .gitea/workflows/build.yaml
All checks were successful
Build e Deploy Direto / build-and-deploy (push) Successful in 52s
2026-02-26 23:44:09 +00:00
1905647822 Atualizar .gitea/workflows/build.yaml
Some checks failed
Build e Deploy Direto / build-and-deploy (push) Failing after 4s
2026-02-26 23:43:09 +00:00
583f0e5193 Atualizar .gitea/workflows/build.yaml
Some checks failed
Build e Deploy Direto / build-and-deploy (push) Failing after 4s
2026-02-26 23:41:50 +00:00
818dcd2606 Atualizar .gitea/workflows/build.yaml
Some checks failed
CI/CD Pipeline Coolify / testes (push) Failing after 16s
CI/CD Pipeline Coolify / deploy-trigger (push) Has been skipped
2026-02-26 23:38:30 +00:00
acbaeba772 Atualizado
Some checks failed
CI/CD Pipeline Coolify / testes (push) Failing after 23s
CI/CD Pipeline Coolify / deploy-trigger (push) Has been skipped
2026-02-26 23:34:49 +00:00
7db9348fa0 Versao do java mudada
Some checks failed
CI/CD Pipeline Coolify / testes (push) Failing after 52s
CI/CD Pipeline Coolify / deploy-trigger (push) Has been skipped
2026-02-26 23:32:14 +00:00
3fef8d8c15 Instalar o maven
Some checks failed
CI/CD Pipeline Coolify / testes (push) Failing after 43s
CI/CD Pipeline Coolify / deploy-trigger (push) Has been skipped
2026-02-26 23:29:54 +00:00
db532b19a6 Atualizado metodo para chamar a webhook
Some checks failed
CI/CD Pipeline Coolify / testes (push) Failing after 5m58s
CI/CD Pipeline Coolify / deploy-trigger (push) Has been skipped
2026-02-26 23:06:50 +00:00
b0a5191239 Build atualizado so para testes
Some checks failed
CI/CD Pipeline Coolify / deploy-trigger (push) Has been cancelled
CI/CD Pipeline Coolify / testes (push) Has been cancelled
2026-02-26 23:02:45 +00:00
7b9e637746 Alterado versao do java no workflow
Some checks failed
Gitea Actions Java Build / build-projeto (push) Failing after 5m57s
2026-02-26 22:50:59 +00:00
c9e4489b4e Adicionar .gitea/workflows/build.yaml
Some checks failed
Gitea Actions Java Build / build-projeto (push) Has been cancelled
2026-02-26 22:42:49 +00:00
16 changed files with 371 additions and 379 deletions

View File

@@ -0,0 +1,36 @@
name: Build e Deploy
run-name: Build & Deploy por ${{ gitea.actor }} 🚀
on:
push:
branches: [ "main", "master" ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout do código
uses: actions/checkout@v4
- name: Configurar JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven' # Esta linha ativa o cache automático das dependências do Maven
- name: Corrigir Instalador e Instalar Maven
run: |
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get install -y maven
- name: Build do JAR (Sem Testes)
run: |
# O -DskipTests ignora os testes e foca só em gerar o arquivo
mvn clean install -DskipTests
- name: Chamar Webhook do Coolify
run: |
curl -X GET "https://coolify.stackpanel.com.br/api/v1/deploy?uuid=iwwcg08c04css0o444k08sgg&force=false" \
-H "Authorization: Bearer 6|JDmqzDFYjZbHKGEt3jjMERvvMTKNsDjsugQQkZtg28e56c42"

View File

@@ -1,20 +1,20 @@
package br.com.stackpanel.api.config; package br.com.stackpanel.api.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient;
@Configuration @Configuration
public class RestClientConfig { public class RestClientConfig {
@Bean @Bean
public RestClient customRestClient(){ public RestClient customRestClient(){
return RestClient.builder() return RestClient.builder()
.baseUrl("https://coolify.stackpanel.com.br") .baseUrl("https://coolify.stackpanel.com.br")
.build(); .build();
} }
} }

View File

@@ -1,40 +1,38 @@
package br.com.stackpanel.api.controller; package br.com.stackpanel.api.controller;
import br.com.stackpanel.api.entity.CoolifyPersistence; import br.com.stackpanel.api.entity.dto.CoolifyResponse;
import br.com.stackpanel.api.entity.dto.CoolifyResponse; import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects;
import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects; import br.com.stackpanel.api.service.CoolifyService;
import br.com.stackpanel.api.service.CoolifyService; import org.springframework.web.bind.annotation.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import java.util.List;
import java.util.List; @CrossOrigin("*")
@RestController
@CrossOrigin("*") @RequestMapping("/projects")
@RestController public class CoolifyController {
@RequestMapping("/projects")
public class CoolifyController {
private final CoolifyService coolifyService;
private final CoolifyService coolifyService; public CoolifyController(CoolifyService coolifyService) {
this.coolifyService = coolifyService;
public CoolifyController(CoolifyService coolifyService) { }
this.coolifyService = coolifyService;
} @GetMapping("/buscar")
public List<CoolifyResponse> buscarProjects(){
@GetMapping("/buscar") return coolifyService.buscarProjects();
public ResponseEntity<List<CoolifyPersistence>> buscarProjects(){ }
return ResponseEntity.ok(coolifyService.buscarProjects());
} @GetMapping("/buscarProject")
public CoolifyResponseProjects buscarProjectsUuid(@RequestParam(name = "uuid") String uuid){
@GetMapping("/buscarProject") return coolifyService.buscarProjetosUuid(uuid);
public CoolifyResponseProjects buscarProjectsUuid(@RequestParam(name = "uuid") String uuid){ }
return coolifyService.buscarProjetosUuid(uuid);
} @GetMapping("/buscarTodos")
public CoolifyResponseProjects buscarTodosProjects(){
@GetMapping("/buscarTodos") return coolifyService.buscarProjetosUuids();
public CoolifyResponseProjects buscarTodosProjects(){ }
return coolifyService.buscarProjetosUuids();
} }
}

View File

@@ -1,73 +1,64 @@
package br.com.stackpanel.api.entity; package br.com.stackpanel.api.entity;
import jakarta.persistence.*; import jakarta.persistence.*;
@Entity @Entity
@Table(name = "TPROJECT", schema = "CLFADM") @Table(name = "TPROJECT", schema = "CLFADM")
public class CoolifyPersistence { public class CoolifyPersistence {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CODPRT") @Column(name = "CODPRT")
private Long sequence; private Long sequence;
@Column(name = "NAMPRT") @Column(name = "NAMPRT")
private String nameProject; private String nameProject;
@Column(name = "UUID", unique = true) @Column(name = "UUID")
private String uuid; private String uudi;
@Column(name = "DSCPRT") @Column(name = "DSCPRT")
private String description; private String description;
public CoolifyPersistence() { public CoolifyPersistence() {
} }
public CoolifyPersistence(String nameProject, String uuid, String description) { public CoolifyPersistence(Long sequence, String nameProject, String uudi, String description) {
this.nameProject = nameProject; this.sequence = sequence;
this.uuid = uuid; this.nameProject = nameProject;
this.description = description; this.uudi = uudi;
} this.description = description;
}
public Long getSequence() {
return sequence; public Long getSequence() {
} return sequence;
}
public void setSequence(Long sequence) {
this.sequence = sequence; public void setSequence(Long sequence) {
} this.sequence = sequence;
}
public String getNameProject() {
return nameProject; public String getNameProject() {
} return nameProject;
}
public void setNameProject(String nameProject) {
this.nameProject = nameProject; public void setNameProject(String nameProject) {
} this.nameProject = nameProject;
}
public String getUuid() {
return uuid; public String getUudi() {
} return uudi;
}
public void setUuid(String uuid) {
this.uuid = uuid; public void setUudi(String uudi) {
} this.uudi = uudi;
}
public String getDescription() {
return description; public String getDescription() {
} return description;
}
public void setDescription(String description) {
this.description = description; public void setDescription(String description) {
} this.description = description;
}
@Override }
public String toString() {
return "CoolifyPersistence{" +
"sequence=" + sequence +
", nameProject='" + nameProject + '\'' +
", uuid='" + uuid + '\'' +
", description='" + description + '\'' +
'}';
}
}

View File

@@ -1,4 +0,0 @@
package br.com.stackpanel.api.entity.dto;
public record ApplicationResponse(String name, String uuid) {
}

View File

@@ -1,4 +1,4 @@
package br.com.stackpanel.api.entity.dto; package br.com.stackpanel.api.entity.dto;
public record CoolifyResponse(Long id, String uuid, String name, String description) { public record CoolifyResponse(Long id, String uuid, String name, String description) {
} }

View File

@@ -1,9 +1,9 @@
package br.com.stackpanel.api.entity.dto; package br.com.stackpanel.api.entity.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List; import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record CoolifyResponseProjects(List<MysqlResponse> mysqls, List<ServiceResponse> services, List<ApplicationResponse> applications, List<PostgreResponse> postgresqls) { public record CoolifyResponseProjects(List<MysqlResponse> mysqls, List<ServiceResponse> services) {
} }

View File

@@ -1,8 +1,8 @@
package br.com.stackpanel.api.entity.dto; package br.com.stackpanel.api.entity.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record MysqlResponse(String name, String uuid, String image, @JsonProperty("public_port") Long publicPort) { public record MysqlResponse(String name, String uuid, String image, @JsonProperty("public_port") Long publicPort) {
} }

View File

@@ -1,4 +0,0 @@
package br.com.stackpanel.api.entity.dto;
public record PostgreResponse(String name, String uuid, String image) {
}

View File

@@ -1,7 +1,7 @@
package br.com.stackpanel.api.entity.dto; package br.com.stackpanel.api.entity.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record ServiceResponse(String name, String uuid) { public record ServiceResponse(String name, String uuid) {
} }

View File

@@ -1,37 +1,38 @@
package br.com.stackpanel.api.entity.mapper; package br.com.stackpanel.api.entity.mapper;
import br.com.stackpanel.api.entity.CoolifyPersistence; import br.com.stackpanel.api.entity.CoolifyPersistence;
import br.com.stackpanel.api.entity.dto.CoolifyResponse; import br.com.stackpanel.api.entity.dto.CoolifyResponse;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@Component @Component
public class CoolifyMapper { public class CoolifyMapper {
public CoolifyPersistence toDomain(CoolifyResponse response){ public CoolifyPersistence toDomain(CoolifyResponse response){
if (response == null){ if (response == null){
return null; return null;
} }
return new CoolifyPersistence( return new CoolifyPersistence(
response.name(), response.id(),
response.uuid(), response.name(),
response.description() response.uuid(),
); response.description()
);
}
}
public List<CoolifyPersistence> toDomainList(List<CoolifyResponse> responses){
if (responses == null){ public List<CoolifyPersistence> toDomainList(List<CoolifyResponse> responses){
return List.of(); if (responses == null){
} return List.of();
}
return responses.stream()
.map(this::toDomain) return responses.stream()
.toList(); .map(this::toDomain)
.toList();
}
}
}
}

View File

@@ -1,43 +1,43 @@
package br.com.stackpanel.api.integration; package br.com.stackpanel.api.integration;
import br.com.stackpanel.api.config.RestClientConfig; import br.com.stackpanel.api.config.RestClientConfig;
import br.com.stackpanel.api.entity.dto.CoolifyResponse; import br.com.stackpanel.api.entity.dto.CoolifyResponse;
import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects; import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient;
import java.util.List; import java.util.List;
@Component @Component
public class CoolifyClient { public class CoolifyClient {
private final RestClient restClientConfig; private final RestClient restClientConfig;
public CoolifyClient(RestClient restClientConfig) { public CoolifyClient(RestClient restClientConfig) {
this.restClientConfig = restClientConfig; this.restClientConfig = restClientConfig;
} }
public List<CoolifyResponse> buscarProjects(){ public List<CoolifyResponse> buscarProjects(){
return this.restClientConfig.get() return this.restClientConfig.get()
.uri("/api/v1/projects/") .uri("/api/v1/projects/")
.accept(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)
.header("Content-Type", "application/json") .header("Content-Type", "application/json")
.header("Authorization", "Bearer 6|JDmqzDFYjZbHKGEt3jjMERvvMTKNsDjsugQQkZtg28e56c42") .header("Authorization", "Bearer 6|JDmqzDFYjZbHKGEt3jjMERvvMTKNsDjsugQQkZtg28e56c42")
.retrieve() .retrieve()
.body(new ParameterizedTypeReference<List<CoolifyResponse>>() {}); .body(new ParameterizedTypeReference<List<CoolifyResponse>>() {});
} }
public CoolifyResponseProjects buscarProjectsUuid(String uuid){ public CoolifyResponseProjects buscarProjectsUuid(String uuid){
return this.restClientConfig.get() return this.restClientConfig.get()
.uri("/api/v1/projects/{uuid}/production", uuid) .uri("/api/v1/projects/{uuid}/production", uuid)
.accept(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)
.header("Content-Type", "application/json") .header("Content-Type", "application/json")
.header("Authorization", "Bearer 6|JDmqzDFYjZbHKGEt3jjMERvvMTKNsDjsugQQkZtg28e56c42") .header("Authorization", "Bearer 6|JDmqzDFYjZbHKGEt3jjMERvvMTKNsDjsugQQkZtg28e56c42")
.retrieve() .retrieve()
.body(new ParameterizedTypeReference<CoolifyResponseProjects>() {}); .body(new ParameterizedTypeReference<CoolifyResponseProjects>() {});
} }
} }

View File

@@ -1,19 +1,14 @@
package br.com.stackpanel.api.repository; package br.com.stackpanel.api.repository;
import br.com.stackpanel.api.entity.CoolifyPersistence; import br.com.stackpanel.api.entity.CoolifyPersistence;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; @Repository
public interface CoolifyRepository extends JpaRepository<CoolifyPersistence, Long> {
@Repository
public interface CoolifyRepository extends JpaRepository<CoolifyPersistence, Long> { @Query(value = "SELECT col FROM CoolifyPersistence col WHERE col.uudi in (:uuid)")
CoolifyPersistence buscarProjectsUUIDs(String uuid);
@Query(value = "SELECT col.uuid FROM CoolifyPersistence col")
List<String> buscarListaUuids(); }
@Query(value = "SELECT col FROM CoolifyPersistence col")
List<CoolifyPersistence> buscarProjects();
}

View File

@@ -1,17 +1,16 @@
package br.com.stackpanel.api.service; package br.com.stackpanel.api.service;
import br.com.stackpanel.api.entity.CoolifyPersistence; import br.com.stackpanel.api.entity.dto.CoolifyResponse;
import br.com.stackpanel.api.entity.dto.CoolifyResponse; import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects;
import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects;
import java.util.List;
import java.util.List;
public interface CoolifyService {
public interface CoolifyService {
List<CoolifyResponse> buscarProjects();
List<CoolifyPersistence> buscarProjects();
CoolifyResponseProjects buscarProjetosUuid(String uuid);
CoolifyResponseProjects buscarProjetosUuid(String uuid);
CoolifyResponseProjects buscarProjetosUuids();
CoolifyResponseProjects buscarProjetosUuids();
}
}

View File

@@ -1,93 +1,73 @@
package br.com.stackpanel.api.service.impl; package br.com.stackpanel.api.service.impl;
import br.com.stackpanel.api.entity.CoolifyPersistence; import br.com.stackpanel.api.entity.CoolifyPersistence;
import br.com.stackpanel.api.entity.dto.*; import br.com.stackpanel.api.entity.dto.CoolifyResponse;
import br.com.stackpanel.api.entity.mapper.CoolifyMapper; import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects;
import br.com.stackpanel.api.integration.CoolifyClient; import br.com.stackpanel.api.entity.dto.MysqlResponse;
import br.com.stackpanel.api.repository.CoolifyRepository; import br.com.stackpanel.api.entity.dto.ServiceResponse;
import br.com.stackpanel.api.service.CoolifyService; import br.com.stackpanel.api.entity.mapper.CoolifyMapper;
import jakarta.transaction.Transactional; import br.com.stackpanel.api.integration.CoolifyClient;
import org.springframework.stereotype.Service; import br.com.stackpanel.api.repository.CoolifyRepository;
import br.com.stackpanel.api.service.CoolifyService;
import java.util.ArrayList; import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List; import java.util.ArrayList;
import java.util.Objects; import java.util.Collection;
import java.util.stream.Collector; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collector;
import java.util.stream.Collectors;
@Service
public class CoolifyServiceImpl implements CoolifyService { @Service
public class CoolifyServiceImpl implements CoolifyService {
private final CoolifyClient coolifyClient;
private final CoolifyRepository repository; private final CoolifyClient coolifyClient;
private final CoolifyMapper mapper; private final CoolifyRepository repository;
private final CoolifyMapper mapper;
public CoolifyServiceImpl(CoolifyClient coolifyClient, CoolifyRepository repository, CoolifyMapper mapper) {
this.coolifyClient = coolifyClient; public CoolifyServiceImpl(CoolifyClient coolifyClient, CoolifyRepository repository, CoolifyMapper mapper) {
this.repository = repository; this.coolifyClient = coolifyClient;
this.mapper = mapper; this.repository = repository;
} this.mapper = mapper;
}
@Override
@Transactional public List<CoolifyResponse> buscarProjects(){
public List<CoolifyPersistence> buscarProjects(){ return coolifyClient.buscarProjects();
}
List<CoolifyResponse> projects = coolifyClient.buscarProjects();
// public List<CoolifyPersistence> salvarProjetos(){
List<String> dbProjects = repository.buscarListaUuids(); // List<CoolifyResponse> response = coolifyClient.buscarProjects();
//
// List<String> uuids = new ArrayList<>();
if (!projects.isEmpty()) { //
projects.stream() // for (CoolifyResponse unique: response) {
.filter(item -> !dbProjects.contains(item.uuid())) // uuids.add(unique.uuid());
.map(mapper::toDomain) // }
.map(this::salvarProjects) //
.forEach(System.out::println); // return uuids;
//
} // }
@Override
return repository.buscarProjects().stream() public CoolifyResponseProjects buscarProjetosUuid(String uuid){
.toList(); return coolifyClient.buscarProjectsUuid(uuid);
}
} @Override
public CoolifyResponseProjects buscarProjetosUuids(){
private CoolifyPersistence salvarProjects(CoolifyPersistence coolifyPersistence){ List<CoolifyResponseProjects> buscarPorUuids = coolifyClient.buscarProjects().stream()
return repository.save(coolifyPersistence); .map(uuids -> coolifyClient.buscarProjectsUuid(uuids.uuid()))
} .toList();
@Override List<MysqlResponse> listaDeMysqls = buscarPorUuids.stream()
public CoolifyResponseProjects buscarProjetosUuid(String uuid){ .flatMap(flat -> flat.mysqls().stream())
return coolifyClient.buscarProjectsUuid(uuid); .toList();
}
List<ServiceResponse> listaDeServices = buscarPorUuids.stream()
@Override .flatMap(flat -> flat.services().stream())
public CoolifyResponseProjects buscarProjetosUuids(){ .toList();
List<CoolifyResponseProjects> buscarPorUuids = coolifyClient.buscarProjects().stream() return new CoolifyResponseProjects(listaDeMysqls, listaDeServices);
.map(uuids -> coolifyClient.buscarProjectsUuid(uuids.uuid()))
.toList(); }
}
List<MysqlResponse> listaDeMysqls = buscarPorUuids.stream()
.flatMap(flat -> flat.mysqls().stream())
.toList();
List<ServiceResponse> listaDeServices = buscarPorUuids.stream()
.flatMap(flat -> flat.services().stream())
.toList();
List<ApplicationResponse> listaDeApplications = buscarPorUuids.stream()
.flatMap(item -> item.applications().stream())
.toList();
List<PostgreResponse> listaDePostgreSql = buscarPorUuids.stream()
.flatMap(item -> item.postgresqls().stream())
.toList();
return new CoolifyResponseProjects(listaDeMysqls, listaDeServices, listaDeApplications, listaDePostgreSql);
}
}

View File

@@ -3,7 +3,7 @@ spring.config.activate.on-profile=local
spring.datasource.password=SnLcLToyTLVlTmODy9X8WkJLxD5M6i7rFJEQPUgnrIqwH9zYpkX7rczfH8wcPSD1 spring.datasource.password=SnLcLToyTLVlTmODy9X8WkJLxD5M6i7rFJEQPUgnrIqwH9zYpkX7rczfH8wcPSD1
spring.datasource.username=nexus spring.datasource.username=nexus
spring.datasource.url=jdbc:postgresql://db.stackpanel.com.br/nexusdb spring.datasource.url=jdbc:postgresql://129.153.206.118:5676/nexusdb
spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update