Update maven-build.yml

This commit is contained in:
Kunchala Vikram 2023-12-30 23:42:44 +05:30 committed by GitHub
parent 1d1efb463c
commit 3f80cdb0b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ on:
branches: [ "main" ] branches: [ "main" ]
env: env:
IMAGE_NAME: "test-maven-app" IMAGE_NAME: "test-maven-app"
DOCKERHUB_USERNAME: "kunchalavikram" DOCKERHUB_USERNAME: "kunchalavikram"
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -18,17 +18,27 @@ jobs:
- name: Setup Java and Maven - name: Setup Java and Maven
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
distribution: 'temurin' # See 'Supported distributions' for available options distribution: 'temurin'
java-version: '11' java-version: '11'
- name: Check java and mvn version
run: |
java -version
mvn --version
- name: Run Tests
run: mvn test
- name: Package the Application - name: Package the Application
run: | run: |
mvn -B package mvn -B package
ls -al ${{ github.workspace }}/target ls -al ${{ github.workspace }}/target
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: war-file
path: target/*.war
if-no-files-found: 'error'
retention-days: 1 day
dockerize:
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: war-file
path: target/*.war
- name: Dockerize the Application - name: Dockerize the Application
run: docker build -t ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME}}:${{ github.run_number }} . run: docker build -t ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME}}:${{ github.run_number }} .