Skip to content

Create maven.yml

Create maven.yml #1

Workflow file for this run

name: Build and Dockerize Java Application
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build-and-dockerize:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Build Docker image
run: docker build -t my-java-app:latest .
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.GITHUB_ACTOR }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to Docker Hub
run: |
docker tag my-java-app:latest Olooce/my-java-app:latest
docker push Olooce/my-java-app:latest