From c98f6ed348d160c1b08383ffff165c9c2ccdb710 Mon Sep 17 00:00:00 2001 From: DaviSantos <101915085+DaveScott99@users.noreply.github.com> Date: Sat, 10 Feb 2024 01:58:58 -0300 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 39 ++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7b7cd2..c707472 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,21 +9,36 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - name: Chechout code + uses: actions/checkout@v4.1.1 + - name: Setup Java + uses: actions/setup-java@v4.0.0 + with: + distribution: 'temurin' + java-version: '17' + + - name: Get short commit hash + id: commit_hash + run: echo "::set-output name=hash::$(git rev-parse --short HEAD)" + + - name: Build project + run: mvn clean install -DskipTests + - name: Login to Docker Hub uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d with: username: ${{secrets.DOCKER_USER}} password: ${{secrets.DOCKER_PWD}} - - - name: BUILD AND PUSH - uses: docker/build-push-action@v5.1.0 - with: - context: ./ - file: ./Dockerfile - push: true - tags: | - ${{ secrets.DOCKER_USER }}/astfx-accserv:${{ github.run_number }} - ${{ secrets.DOCKER_USER }}/astfx-accserv:latest - + + - name: Build Docker image version tag + run: docker build -t ${{ secrets.DOCKER_USER }}/astfx-accserv:v1.${{ github.run_number }}.${{ steps.commit_hash.outputs.hash }} . + + - name: Build Docker image latest tag + run: docker build -t ${{ secrets.DOCKER_USER }}/astfx-accserv:latest . + + - name: Push image Docker with version tag + run: docker push ${{ secrets.DOCKER_USER }}/astfx-accserv:v1.${{ github.run_number }}.${{ steps.commit_hash.outputs.hash }} + + - name: Push image Docker with latest tag + run: docker push ${{ secrets.DOCKER_USER }}/astfx-accserv:latest