Skip to content
Closed
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
35 changes: 25 additions & 10 deletions .github/workflows/basic-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
name: Continuous integration example

on:
push:
workflow_dispatch:

jobs:

test:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- run: mvn test
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven' # Opcional: Acelera las builds futuras cacheando las dependencias

- name: Generate tag
run: echo "tag=$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout)" > $GITHUB_OUTPUT
id: project
- name: Generate Docker image
# Si tu pom.xml está en una subcarpeta (ej. /backend), descomenta la siguiente línea:
# working-directory: ./ruta-a-tu-carpeta
run: mvn spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=${{ secrets.DOCKERHUB_USERNAME }}/posts:${{steps.project.outputs.tag}}

- name: Login to DockerHub
run: docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}"

- name: Push image to DockerHub
# Corregido: Debe coincidir exactamente con el imageName del paso de Maven
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/posts:${{steps.project.outputs.tag}}
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>es.codeurjc.test</groupId>
<artifactId>calculadora</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.0-</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -48,6 +48,14 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>

<configuration>
<mainClass>es.codeurjc.test.ejem.Calculadora</mainClass>
</configuration>
</plugin>
</plugins>
</build>

Expand Down