Skip to content

Commit

Permalink
Merge pull request #9 from FusionTech-2430/develop
Browse files Browse the repository at this point in the history
🚀 Changes finished v1
  • Loading branch information
Estebans441 authored Oct 7, 2024
2 parents 8903efe + 1efe5b0 commit 142d541
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 108 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build Project
on:
pull_request:
branches: [ "main", "develop", "release" ]

jobs:
Build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

- name: Build with Maven
env:
CONFIG_IP: ${{ secrets.DEV_INTEG_HOST }}
run: mvn clean install
49 changes: 8 additions & 41 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,16 @@
name: Deploy Develop
on:
push:
branches: ["develop"]
pull_request:
branches: ["develop"]
branches:
- develop
types:
- closed
workflow_dispatch:
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Maven
run: sudo apt-get install -y maven
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
cache: maven
- name: Build with Maven
env:
DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }}
DATASOURCE_URL: ${{ secrets.NEON_DATASOURCE_URL }}/${{ secrets.DB_NAME }}
DATASOURCE_USERNAME: ${{ secrets.DATASOURCE_USERNAME }}
GOOGLE_ADMIN_CONFIG_TYPE: ${{ secrets.GOOGLE_ADMIN_CONFIG_TYPE }}
GOOGLE_ADMIN_CONFIG_PROJECT_ID: ${{ secrets.GOOGLE_ADMIN_CONFIG_PROJECT_ID }}
GOOGLE_ADMIN_CONFIG_PRIVATE_KEY: ${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY }}
GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID: ${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID }}
GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL: ${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL }}
GOOGLE_ADMIN_CONFIG_CLIENT_ID: ${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_ID }}
GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL: ${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL }}
run: mvn clean install

deploy:
Deploy:
name: Deploy on Develop
if: ${{ github.event.pull_request.merged == true }}
runs-on: self-hosted
needs: Build
steps:
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
Expand All @@ -53,16 +28,8 @@ jobs:
echo "Building Docker image..."
docker build -t ${{ github.event.repository.name }} .
echo "Creating .env file..."
echo "DATASOURCE_URL=${{ secrets.DEV_DATASOURCE_URL }}/${{ secrets.DB_NAME }}" >> .env
echo "DATASOURCE_USERNAME=${{ secrets.DATASOURCE_USERNAME }}" >> .env
echo "DATASOURCE_PASSWORD=${{ secrets.DATASOURCE_PASSWORD }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_TYPE=${{ secrets.GOOGLE_ADMIN_CONFIG_TYPE }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_PROJECT_ID=${{ secrets.GOOGLE_ADMIN_CONFIG_PROJECT_ID }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_PRIVATE_KEY=${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID=${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL=${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_CLIENT_ID=${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_ID }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_X509_CERT_URL=${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL }}" >> .env
echo "PROFILE=dev" >> .env
echo "CONFIG_IP=10.43.101.114" >> .env
docker rm -f ${{ github.event.repository.name }}
docker run --name ${{ github.event.repository.name }} --network all_connected -d -p ${{ secrets.SERVICE_PORT }}:8080 --env-file .env ${{ github.event.repository.name }}
echo "Docker container running..."
Expand Down
49 changes: 8 additions & 41 deletions .github/workflows/deploy-qa.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,16 @@
name: Deploy QA
on:
push:
branches: ["release"]
pull_request:
branches: ["release"]
branches:
- release
types:
- closed
workflow_dispatch:
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Maven
run: sudo apt-get install -y maven
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
cache: maven
- name: Build with Maven
env:
DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }}
DATASOURCE_URL: ${{ secrets.NEON_DATASOURCE_URL }}/${{ secrets.DB_NAME }}
DATASOURCE_USERNAME: ${{ secrets.DATASOURCE_USERNAME }}
GOOGLE_ADMIN_CONFIG_TYPE: ${{ secrets.GOOGLE_ADMIN_CONFIG_TYPE }}
GOOGLE_ADMIN_CONFIG_PROJECT_ID: ${{ secrets.GOOGLE_ADMIN_CONFIG_PROJECT_ID }}
GOOGLE_ADMIN_CONFIG_PRIVATE_KEY: ${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY }}
GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID: ${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID }}
GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL: ${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL }}
GOOGLE_ADMIN_CONFIG_CLIENT_ID: ${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_ID }}
GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL: ${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL }}
run: mvn clean install

Deploy:
name: Deploy on QA
if: ${{ github.event.pull_request.merged == true }}
runs-on: self-hosted
needs: Build
steps:
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
Expand All @@ -53,17 +28,9 @@ jobs:
echo "Building Docker image..."
docker build -t ${{ github.event.repository.name }} .
echo "Creating .env file..."
echo "DATASOURCE_URL=${{ secrets.QA_DATASOURCE_G1_URL }}/${{ secrets.DB_NAME }}" >> .env
echo "DATASOURCE_USERNAME=${{ secrets.DATASOURCE_USERNAME }}" >> .env
echo "DATASOURCE_PASSWORD=${{ secrets.DATASOURCE_PASSWORD }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_TYPE=${{ secrets.GOOGLE_ADMIN_CONFIG_TYPE }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_PROJECT_ID=${{ secrets.GOOGLE_ADMIN_CONFIG_PROJECT_ID }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_PRIVATE_KEY=${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID=${{ secrets.GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL=${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_CLIENT_ID=${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_ID }}" >> .env
echo "GOOGLE_ADMIN_CONFIG_X509_CERT_URL=${{ secrets.GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL }}" >> .env
echo "PROFILE=qa1" >> .env
echo "CONFIG_IP=10.43.100.223" >> .env
docker rm -f ${{ github.event.repository.name }}
docker run --name ${{ github.event.repository.name }} --network all_connected -d -p ${{ secrets.SERVICE_PORT }}:8080 --env-file .env ${{ github.event.repository.name }}
echo "Docker container running..."
rm .env
rm .env
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -64,6 +71,14 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public ResponseEntity<?> getUsers(
) {
try {
UserDTO[] listUsersDTO = userService.getUsers(fullname, username, mail, rol, active);
if (listUsersDTO.length == 0)
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new Response(HttpStatus.NOT_FOUND.value(), "No users found"));
return ResponseEntity.status(HttpStatus.OK).body(listUsersDTO);
} catch (OperationException e) {
return ResponseEntity.status(e.getCode()).body(new Response(e.getCode(), e.getMessage()));
Expand Down
27 changes: 4 additions & 23 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@

spring:
application:
name: users-service
datasource:
url: ${DATASOURCE_URL}
username: ${DATASOURCE_USERNAME}
password: ${DATASOURCE_PASSWORD}
driver-class-name: org.postgresql.Driver
eureka:
client:
enabled: false

firebase:
type: ${GOOGLE_ADMIN_CONFIG_TYPE}
project-id: ${GOOGLE_ADMIN_CONFIG_PROJECT_ID}
private-key: ${GOOGLE_ADMIN_CONFIG_PRIVATE_KEY}
private-key-id: ${GOOGLE_ADMIN_CONFIG_PRIVATE_KEY_ID}
client-email: ${GOOGLE_ADMIN_CONFIG_CLIENT_EMAIL}
client-id: ${GOOGLE_ADMIN_CONFIG_CLIENT_ID}
auth-uri: https://accounts.google.com/o/oauth2/auth
token-uri: https://oauth2.googleapis.com/token
auth-provider-x509-cert-url: https://www.googleapis.com/oauth2/v1/certs
client-x509-cert-url: ${GOOGLE_ADMIN_CONFIG_CLIENT_X509_CERT_URL}
universe-domain: googleapis.com

config:
import: configserver:http://${CONFIG_IP:localhost}:8888
profiles:
active: ${PROFILE:keveldev}

0 comments on commit 142d541

Please sign in to comment.