Skip to content

Commit 8cdd881

Browse files
committed
add documentation to work flow
1 parent 815d414 commit 8cdd881

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/maven.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14+
# 📥 Obtener el código fuente del repositorio
1415
- name: Checkout repo
1516
uses: actions/checkout@v4
1617

18+
# ☕ Configurar JDK 17 y cachear dependencias de Maven
1719
- name: Set up JDK 17
1820
uses: actions/setup-java@v4
1921
with:
2022
java-version: '17'
2123
distribution: 'temurin'
2224
cache: maven
2325

26+
# 🔨 Compilar y ejecutar pruebas con Maven
2427
- name: Build with Maven
2528
run: mvn -B -V -DskipTests=false verify
2629

@@ -35,16 +38,19 @@ jobs:
3538
# target/**
3639
# if-no-files-found: warn
3740

41+
# 📦 Copiar el JAR generado al contexto de Docker
3842
- name: Copy JAR to docker context
3943
run: |
4044
mkdir -p dockerfile
4145
echo "Jar files in target:"
4246
ls -la target/*.jar || true
4347
cp target/*.jar dockerfile/ || true
4448
49+
# 🐳 Construir imagen Docker con el JAR
4550
- name: Build Docker image
4651
run: docker build -f dockerfile/Dockerfile -t my-app-image:${{ github.sha }} dockerfile/
4752

53+
# 🔍 Escanear vulnerabilidades de la imagen con Trivy
4854
- name: Scan Docker image with Trivy
4955
uses: aquasecurity/trivy-action@0.33.1
5056
continue-on-error: true
@@ -54,13 +60,15 @@ jobs:
5460
severity: CRITICAL,HIGH
5561
vuln-type: os,library
5662

63+
# 🔑 Autenticarse en GitHub Container Registry
5764
- name: Log in to GitHub Container Registry
5865
uses: docker/login-action@v2
5966
with:
6067
registry: ghcr.io
6168
username: ${{ github.actor }}
6269
password: ${{ secrets.GITHUB_TOKEN }}
6370

71+
# 📤 Construir y publicar imagen en GHCR con dos tags (latest y commit SHA)
6472
- name: Build and push to GHCR
6573
uses: docker/build-push-action@v4
6674
with:
@@ -71,12 +79,15 @@ jobs:
7179
ghcr.io/${{ github.repository_owner }}/my-app-image:latest
7280
ghcr.io/${{ github.repository_owner }}/my-app-image:${{ github.sha }}
7381
82+
# 🚀 Desplegar contenedor localmente para pruebas rápidas
7483
- name: Deploy Docker container
7584
run: |
7685
docker run -d --name my-app-container -p 8080:8080 ghcr.io/jsgiraldoh/my-app-image:${{ github.sha }}
7786
87+
# 📜 Mostrar logs del contenedor en ejecución
7888
- name: Show Docker container logs
7989
run: docker logs -f my-app-container
8090

91+
# 🧹 Eliminar contenedor al finalizar
8192
- name: Remove Docker container
8293
run: docker container rm -f my-app-container

src/main/java/com/mycompany/app/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
public class App {
77

8-
private static final String MESSAGE = "Hello World from Github Actions 3!";
8+
private static final String MESSAGE = "Hello World from Github Actions!";
99

1010
public App() {}
1111

src/test/java/com/mycompany/app/AppTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public void testAppConstructor() {
2020
public void testAppMessage()
2121
{
2222
App app = new App();
23-
assertEquals("Hello World from Github Actions 3!", app.getMessage());
23+
assertEquals("Hello World from Github Actions!", app.getMessage());
2424
}
2525
}

0 commit comments

Comments
 (0)