From 4901cee7638aa4ef063fd08c228a31d3aca70a54 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 15:24:54 +0330 Subject: [PATCH] refactor ci.yml --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65e48ef..66ed5ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: run: dotnet test -c Release --no-restore - name: Update Release Drafter - if: github.ref == 'refs/heads/main' + if: ${{ github.ref == 'refs/heads/main' && success() }} id: last_release uses: release-drafter/release-drafter@v5 env: @@ -49,13 +49,13 @@ jobs: ##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions - name: Login to DockerHub uses: docker/login-action@v2 - if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }} + if: ${{ github.ref == 'refs/heads/main' && success() }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build Docker Image - if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }} + if: ${{ github.ref == 'refs/heads/main' && success() }} run: | docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . @@ -63,7 +63,7 @@ jobs: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - name: Publish Docker Image - if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }} + if: ${{ github.ref == 'refs/heads/main' && success() }} run: | docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }} docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }}