Skip to content

Commit

Permalink
Create maven.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Olooce authored Aug 16, 2024
1 parent 68807ee commit 61985c0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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

0 comments on commit 61985c0

Please sign in to comment.