From 0fbade9d5ad815b91cf1cf6d4e20a9da25b27c60 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:28:46 +0330 Subject: [PATCH] refactor ci.yml --- .github/workflows/ci.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 534748c..4bb34f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,27 +34,23 @@ jobs: run: dotnet build -c Release --no-restore - name: Test - if: success() + if: ${{success()}} run: dotnet test -c Release --no-restore - name: Update Release Drafter if: | - github.ref == 'refs/heads/main' && - success() + ${{github.ref == 'refs/heads/main'}} && + ${{success()}} id: last_release uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: "Print result" - run: | - echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" - echo "name: ${{ steps.last_release.outputs.name }}" - echo "id: ${{ steps.last_release.outputs.id }}" - name: Login to DockerHub if: | - github.ref == 'refs/heads/main' && - success() + ${{github.ref == 'refs/heads/main'}} && + ${{success()}} && + ${{ steps.last_release.outputs.tag_name }} != '' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -64,8 +60,9 @@ jobs: ##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions - name: Build Docker Image if: | - github.ref == 'refs/heads/main' && - success() + ${{github.ref == 'refs/heads/main'}} && + ${{success()}} && + ${{ steps.last_release.outputs.tag_name }} != '' 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" . @@ -74,8 +71,9 @@ jobs: - name: Publish Docker Image if: | - github.ref == 'refs/heads/main' && - success() + ${{github.ref == 'refs/heads/main'}} && + ${{success()}} && + ${{ steps.last_release.outputs.tag_name }} != '' 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 }}