From 61985c0f766a22014eadf1b1efe486db14909d57 Mon Sep 17 00:00:00 2001 From: Oloo <121952433+Olooce@users.noreply.github.com> Date: Fri, 16 Aug 2024 19:22:43 +0300 Subject: [PATCH] Create maven.yml --- .github/workflows/maven.yml | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..3c74262 --- /dev/null +++ b/.github/workflows/maven.yml @@ -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