From e218674ac735384148b22c43e020cec5e757b6bb Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 00:39:32 +0330 Subject: [PATCH 01/15] change in release drafter template --- .github/release-drafter.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index b3c5e9a..426e305 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -8,11 +8,12 @@ # This release drafter follows the conventions from https://keepachangelog.com, https://common-changelog.org/ # https://www.conventionalcommits.org - +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' template: | ## What Changed 👀 $CHANGES - + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION categories: - title: 🚀 Features labels: From c1a6b4591551cb08daf534a68c1b75b7b85bedc3 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 00:45:58 +0330 Subject: [PATCH 02/15] some check in ci.yml --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26a28ec..3ffcc0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,17 +34,18 @@ jobs: run: dotnet build -c Release --no-restore - name: Test + if: ${{ success() }} run: dotnet test -c Release --no-restore - name: Update Release Drafter - if: github.ref == 'refs/heads/main' + if: ${{ success() }} and github.ref == 'refs/heads/main' id: last_release uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Login to DockerHub - if: github.ref == 'refs/heads/main' + if: ${{ success() }} and github.ref == 'refs/heads/main' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -53,7 +54,7 @@ jobs: ##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' + if: ${{ success() }} and github.ref == 'refs/heads/main' 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" . @@ -61,7 +62,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' + if: ${{ success() }} and github.ref == 'refs/heads/main' 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 }} From fabbc3983ef9d8acf317357161b0d5761b61d549 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:01:27 +0330 Subject: [PATCH 03/15] refactor ci.yml --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ffcc0c..e995c4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,18 +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: ${{ success() }} and github.ref == 'refs/heads/main' + if: and(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: ${{ success() }} and github.ref == 'refs/heads/main' + if: and(github.ref == 'refs/heads/main', success()) uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -54,7 +59,7 @@ jobs: ##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: ${{ success() }} and github.ref == 'refs/heads/main' + if: and(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" . @@ -62,7 +67,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: ${{ success() }} and github.ref == 'refs/heads/main' + if: and(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 }} From 87e1ebeebd6425dca952eda1aa8dc4218f6bdc67 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:08:11 +0330 Subject: [PATCH 04/15] refactor ci.yml --- .github/workflows/ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e995c4f..534748c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,9 @@ jobs: run: dotnet test -c Release --no-restore - name: Update Release Drafter - if: and(github.ref == 'refs/heads/main', success()) + if: | + github.ref == 'refs/heads/main' && + success() id: last_release uses: release-drafter/release-drafter@v5 env: @@ -50,7 +52,9 @@ jobs: echo "id: ${{ steps.last_release.outputs.id }}" - name: Login to DockerHub - if: and(github.ref == 'refs/heads/main', success()) + if: | + github.ref == 'refs/heads/main' && + success() uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -59,7 +63,9 @@ jobs: ##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: and(github.ref == 'refs/heads/main', success()) + 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" . @@ -67,7 +73,9 @@ 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: and(github.ref == 'refs/heads/main', success()) + 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 }} From 0fbade9d5ad815b91cf1cf6d4e20a9da25b27c60 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:28:46 +0330 Subject: [PATCH 05/15] 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 }} From 6263cbb75e023b348f7f4e750042f772349ae69b Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:44:09 +0330 Subject: [PATCH 06/15] refactor ci.yml --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bb34f8..844a2af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,29 @@ jobs: key: ${{ runner.os }}-dotnet-nuget path: ~/.nuget/packages + - name: Update Release Drafter + if: | + ${{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 "branch: ${{ github.ref }}" + echo "branch: ${{ github.ref }}" + + - name: Login to DockerHub + if: | + ${{ steps.last_release.outputs.tag_name }} != null + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Restore dependencies run: dotnet restore @@ -37,27 +60,8 @@ jobs: if: ${{success()}} run: dotnet test -c Release --no-restore - - name: Update Release Drafter - if: | - ${{github.ref == 'refs/heads/main'}} && - ${{success()}} - id: last_release - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to DockerHub - if: | - ${{github.ref == 'refs/heads/main'}} && - ${{success()}} && - ${{ steps.last_release.outputs.tag_name }} != '' - uses: docker/login-action@v2 - 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 + ##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'}} && From 810ac3cdfba4afe12b858b81cb1a847c449d46e4 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:47:29 +0330 Subject: [PATCH 07/15] refactor --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 844a2af..95e3131 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,9 +28,7 @@ jobs: path: ~/.nuget/packages - name: Update Release Drafter - if: | - ${{github.ref == 'refs/heads/main'}} && - ${{success()}} + if: github.ref == 'refs/heads/main' id: last_release uses: release-drafter/release-drafter@v5 env: @@ -39,9 +37,12 @@ jobs: - 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 "branch: ${{ github.ref }}" echo "branch: ${{ github.ref }}" + - name: Login to DockerHub if: | ${{ steps.last_release.outputs.tag_name }} != null From 07d62195f858708a76da5a8112d51271c6eda901 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:50:56 +0330 Subject: [PATCH 08/15] refactor --- .github/workflows/ci.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95e3131..4eda52c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,19 +16,9 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - - - name: Cache NuGet Packages - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-dotnet-nuget - path: ~/.nuget/packages - name: Update Release Drafter - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' && ${{ steps.last_release.outputs.tag_name }} != null id: last_release uses: release-drafter/release-drafter@v5 env: @@ -44,13 +34,24 @@ jobs: - name: Login to DockerHub - if: | - ${{ steps.last_release.outputs.tag_name }} != null + if: ${{ steps.last_release.outputs.tag_name }} != null uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 7.0.x + + - name: Cache NuGet Packages + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-dotnet-nuget + path: ~/.nuget/packages + + - name: Restore dependencies run: dotnet restore From 3254a85e1d876a3d82c69784de0ffaaf6a942ac6 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:53:27 +0330 Subject: [PATCH 09/15] refactor --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eda52c..03d8873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v3 - name: Update Release Drafter - if: github.ref == 'refs/heads/main' && ${{ steps.last_release.outputs.tag_name }} != null + if: github.ref == 'refs/heads/main' id: last_release uses: release-drafter/release-drafter@v5 env: @@ -34,7 +34,7 @@ jobs: - name: Login to DockerHub - if: ${{ steps.last_release.outputs.tag_name }} != null + if: ${{ steps.last_release.outputs.name }} != null uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From 3ea4e2e9b6e7161a25e3d6f4b6d8723155d9d572 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:54:34 +0330 Subject: [PATCH 10/15] refactor --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03d8873..5e8b559 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: - name: Login to DockerHub - if: ${{ steps.last_release.outputs.name }} != null + if: ${{ steps.last_release.outputs.name }} != '' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From 6ce7dd7b4ab010dd810fbda4fc7a93f4809f5459 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 01:58:31 +0330 Subject: [PATCH 11/15] refactor --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e8b559..540c6dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: - name: Login to DockerHub - if: ${{ steps.last_release.outputs.name }} != '' + if: ${{ steps.last_release.outputs.tag_name }} != 0 uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From 627b2e60b9ee8fb908bddd16241bc2bcba793824 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 02:03:52 +0330 Subject: [PATCH 12/15] refactor --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 540c6dd..8a53ac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Print result" + if: success() run: | echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" echo "name: ${{ steps.last_release.outputs.name }}" @@ -34,7 +35,7 @@ jobs: - name: Login to DockerHub - if: ${{ steps.last_release.outputs.tag_name }} != 0 + if: success() uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From 9b3477fcb9da6b49f2d830f02332d280a68cb935 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 02:08:19 +0330 Subject: [PATCH 13/15] refactor --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a53ac6..d362543 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Print result" - if: success() run: | echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" echo "name: ${{ steps.last_release.outputs.name }}" @@ -35,8 +34,8 @@ jobs: - name: Login to DockerHub - if: success() uses: docker/login-action@v2 + if: ${{ success() && github.event_name == 'pull_request' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} From 4828c06e4469df761670d8801b366251450cc786 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 02:09:48 +0330 Subject: [PATCH 14/15] refactor --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d362543..c1287a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v2 - if: ${{ success() && github.event_name == 'pull_request' }} + if: ${{ success() && steps.last_release.outputs.tag_name != '' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} From afe1d917bee24fcf2b848b6e44be73b0a25aa768 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Thu, 26 Jan 2023 02:13:37 +0330 Subject: [PATCH 15/15] refactor --- .github/workflows/ci.yml | 49 ++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1287a0..03aac82 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 - if: github.ref == 'refs/heads/main' - 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 "branch: ${{ github.ref }}" - echo "branch: ${{ github.ref }}" - - - - name: Login to DockerHub - uses: docker/login-action@v2 - if: ${{ 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: @@ -59,16 +36,27 @@ jobs: run: dotnet build -c Release --no-restore - name: Test - if: ${{success()}} 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 - name: Build Docker Image - if: | - ${{github.ref == 'refs/heads/main'}} && - ${{success()}} && - ${{ steps.last_release.outputs.tag_name }} != '' + if: ${{ 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" . @@ -76,10 +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() && 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 }}