From 1f8d902cad0467bc70f48fa85313435898cb7966 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 02:54:53 +0330 Subject: [PATCH 1/3] refactor --- .github/workflows/ci.yml | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03aac82..826c32f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,27 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Update Release Drafter + 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 }}" + echo "body: ${{ steps.last_release.outputs.body }}" + echo "branch: ${{ github.ref }}" + + - name: Login to DockerHub + uses: docker/login-action@v2 + if: ${{ github.ref == 'refs/heads/main' && success() && steps.last_release.outputs.tag_name != '' }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Setup .NET uses: actions/setup-dotnet@v2 with: @@ -38,20 +59,6 @@ jobs: - name: Test run: dotnet test -c Release --no-restore - - name: Update Release Drafter - if: github.ref == 'refs/heads/main' - id: last_release - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - - name: Login to DockerHub - uses: docker/login-action@v2 - if: ${{ github.ref == 'refs/heads/main' && success() && steps.last_release.outputs.tag_name != '' }} - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} ##ref: https://docs.docker.com/language/golang/configure-ci-cd/ ##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions From c8c81a6f1072a5decd4f9150ebb502f9fbbcb4c4 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 03:02:13 +0330 Subject: [PATCH 2/3] refactor --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 826c32f..a306e4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,8 @@ jobs: echo "name: ${{ steps.last_release.outputs.name }}" echo "id: ${{ steps.last_release.outputs.id }}" echo "body: ${{ steps.last_release.outputs.body }}" + echo "body: ${{ steps.last_release.outputs.html_url }}" + echo "body: ${{ steps.last_release.inputs.version }}" echo "branch: ${{ github.ref }}" - name: Login to DockerHub From efbf1b53e2ad5d2251644b95210884c50a72f176 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 03:22:54 +0330 Subject: [PATCH 3/3] refactor --- .github/workflows/ci.yml | 41 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a306e4e..20f42f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,29 +17,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Update Release Drafter - 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 }}" - echo "body: ${{ steps.last_release.outputs.body }}" - echo "body: ${{ steps.last_release.outputs.html_url }}" - echo "body: ${{ steps.last_release.inputs.version }}" - echo "branch: ${{ github.ref }}" - - - name: Login to DockerHub - uses: docker/login-action@v2 - if: ${{ github.ref == 'refs/heads/main' && success() && steps.last_release.outputs.tag_name != '' }} - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Setup .NET uses: actions/setup-dotnet@v2 with: @@ -61,11 +38,25 @@ jobs: - name: Test run: dotnet test -c Release --no-restore + - name: Update Release Drafter + if: github.ref == 'refs/heads/main' + id: last_release + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + - name: Login to DockerHub + uses: docker/login-action@v2 + if: ${{ github.ref == 'refs/heads/main' && success() }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} ##ref: https://docs.docker.com/language/golang/configure-ci-cd/ ##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() && steps.last_release.outputs.tag_name != '' }} + 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" . @@ -73,7 +64,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() && steps.last_release.outputs.tag_name != '' }} + 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 }}