-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #5 from FusionTech-2430/release
🚀 Release v1.0
- Loading branch information
Showing
40 changed files
with
1,125 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,22 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Build Project | ||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
branches: [ "main", "develop", "release" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
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: 'corretto' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Build with Maven | ||
env: | ||
DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }} | ||
DATASOURCE_URL: ${{ secrets.DATASOURCE_URL }} | ||
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 }} | ||
CONFIG_IP: ${{ secrets.DEV_INTEG_HOST }} | ||
run: mvn clean install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Deploy Develop | ||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
types: | ||
- closed | ||
workflow_dispatch: | ||
jobs: | ||
Deploy: | ||
name: Deploy on Develop | ||
if: ${{ github.event.pull_request.merged == true }} | ||
runs-on: self-hosted | ||
steps: | ||
- name: executing remote ssh commands using ssh key | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.DEV_HOST }} | ||
username: ${{ secrets.HOSTS_USERNAME }} | ||
key: ${{ secrets.DEV_SSH_KEY }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: | | ||
cd AllConnected/${{ github.event.repository.name }} | ||
echo "Fetching latest code..." | ||
git fetch | ||
git checkout develop | ||
git pull | ||
echo "Building Docker image..." | ||
docker build -t ${{ github.event.repository.name }} . | ||
echo "Creating .env file..." | ||
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..." | ||
rm .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Deploy PROD | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
jobs: | ||
Deploy: | ||
name: Deploy on PROD | ||
runs-on: self-hosted | ||
steps: | ||
- name: executing remote ssh commands using ssh key | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.PROD_G1_HOST }} | ||
username: ${{ secrets.HOSTS_USERNAME }} | ||
key: ${{ secrets.PROD_G1_SSH_KEY }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: | | ||
cd AllConnected/${{ github.event.repository.name }} | ||
echo "Fetching latest code..." | ||
git fetch | ||
git checkout main | ||
git pull | ||
echo "Building Docker image..." | ||
docker build -t ${{ github.event.repository.name }} . | ||
echo "Creating .env file..." | ||
echo "PROFILE=prod1" >> .env | ||
echo "CONFIG_IP=10.43.101.72" >> .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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Deploy QA | ||
on: | ||
pull_request: | ||
branches: | ||
- release | ||
types: | ||
- closed | ||
workflow_dispatch: | ||
jobs: | ||
Deploy: | ||
name: Deploy on QA | ||
if: ${{ github.event.pull_request.merged == true }} | ||
runs-on: self-hosted | ||
steps: | ||
- name: executing remote ssh commands using ssh key | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.QA_G1_HOST }} | ||
username: ${{ secrets.HOSTS_USERNAME }} | ||
key: ${{ secrets.QA_G1_SSH_KEY }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: | | ||
cd AllConnected/${{ github.event.repository.name }} | ||
echo "Fetching latest code..." | ||
git fetch | ||
git checkout release | ||
git pull | ||
echo "Building Docker image..." | ||
docker build -t ${{ github.event.repository.name }} . | ||
echo "Creating .env file..." | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Etapa 1: Build | ||
FROM maven:3.9.4-eclipse-temurin-21 AS build | ||
|
||
WORKDIR /app | ||
|
||
# Copiar el pom y código fuente | ||
COPY pom.xml ./ | ||
RUN mvn dependency:go-offline | ||
|
||
COPY src ./src | ||
|
||
RUN mvn clean package -DskipTests | ||
|
||
# Etapa 2: Run | ||
FROM eclipse-temurin:21-jdk-jammy | ||
|
||
WORKDIR /app | ||
|
||
# Copiar el jar generado desde la etapa de build | ||
COPY --from=build /app/target/*.jar app.jar | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/co/allconnected/fussiontech/eventsservice/config/FirebaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package co.allconnected.fussiontech.eventsservice.config; | ||
|
||
import com.google.auth.oauth2.GoogleCredentials; | ||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.FirebaseOptions; | ||
import com.google.gson.Gson; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
@Configuration | ||
public class FirebaseConfig { | ||
|
||
private final FirebaseConfigProperties firebaseConfigProperties; | ||
|
||
public FirebaseConfig(FirebaseConfigProperties firebaseConfigProperties) { | ||
this.firebaseConfigProperties = firebaseConfigProperties; | ||
} | ||
|
||
@PostConstruct | ||
public FirebaseApp initializeFirebase() throws IOException { | ||
firebaseConfigProperties.setPrivate_key( | ||
firebaseConfigProperties.getPrivate_key().replace("\\n", "\n") | ||
); | ||
|
||
String json = new Gson().toJson(firebaseConfigProperties); | ||
|
||
GoogleCredentials credentials = GoogleCredentials.fromStream(new ByteArrayInputStream(json.getBytes())); | ||
|
||
FirebaseOptions options = FirebaseOptions.builder() | ||
.setCredentials(credentials) | ||
.setStorageBucket(firebaseConfigProperties.getProject_id()+".appspot.com") | ||
.build(); | ||
|
||
if(FirebaseApp.getApps().isEmpty()) { | ||
FirebaseApp.initializeApp(options); | ||
} | ||
|
||
return FirebaseApp.getInstance(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/co/allconnected/fussiontech/eventsservice/config/FirebaseConfigProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package co.allconnected.fussiontech.eventsservice.config; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = "firebase") | ||
@Data | ||
public class FirebaseConfigProperties { | ||
private String type; | ||
private String project_id; | ||
private String private_key; | ||
private String private_key_id; | ||
private String client_email; | ||
private String client_id; | ||
private String auth_uri; | ||
private String token_uri; | ||
private String auth_provider_x509_cert_url; | ||
private String client_x509_cert_url; | ||
private String universe_domain; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/co/allconnected/fussiontech/eventsservice/config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package co.allconnected.fussiontech.eventsservice.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOriginPatterns("*") | ||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") | ||
.allowedHeaders("*") | ||
.allowCredentials(true); | ||
} | ||
} |
Oops, something went wrong.