Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/despliegue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI-MICROSERVICIOS-JAVA-DANTONBUSTOS
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Clonacion de codigo
uses: actions/checkout@v4

- name: Setup Java JDK
uses: actions/setup-java@v4.2.1
with:
java-version: '8'
distribution: 'temurin'

- name: Compilacion
run: |
mvn package

- name: Ejecucion Test Unitarios
run: |
mvn package test

- name: Setup Java JDK
uses: actions/setup-java@v4.2.1
with:
java-version: '17'
distribution: 'temurin'

- name: Analisis SonarCloud
run: |
mvn clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar \
-Dsonar.token=${{ secrets.SONAR_TOKEN }} \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=dantonbustos \
-Dsonar.projectKey=dantonbustos_microservicio-java

- name: SonarQube Quality Gate Check
# You may pin to the exact commit or the version.
# uses: SonarSource/sonarqube-quality-gate-action@d304d050d930b02a896b0f85935344f023928496
uses: SonarSource/sonarqube-quality-gate-action@v1.1.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
# Location of the scanner metadata report file
scanMetadataReportFile: target/sonar/report-task.txt


- name: Docker Login
uses: docker/login-action@v3.1.0
with:
username: dantonbustos
password: ${{ secrets.DOCKER_PASS }}

- name: Set up Docker
uses: docker/setup-buildx-action@v3

- name: Docker build
run: |
docker build -t dantonbustos/microservicio-java:latest .


- name: Docker push
run: |
docker push dantonbustos/microservicio-java:latest

deploy:
needs: build
runs-on: self-hosted

steps:

- name: Clonacion de codigo
uses: actions/checkout@v4

- name: Despliegue
run: |
kubectl apply -f deploy.yaml
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/*.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
19 changes: 19 additions & 0 deletions deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: microservicio-java
spec:
replicas: 3
selector:
matchLabels:
app: microservicio-java
template:
metadata:
labels:
app: microservicio-java
spec:
containers:
- name: microservicio-java
image: dantonbustos/microservicio-java:latest
ports:
- containerPort: 8080