From 5c958636e95472023c9ab85e393a6e515c7cf4df Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:05:26 +0330 Subject: [PATCH 01/17] . --- .github/workflows/build-publish-docker.yml | 25 +++++++++++++++------- update-version.sh | 7 ++++++ 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 update-version.sh diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index f418cbb..a5634c9 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -37,6 +37,15 @@ jobs: echo ${{ steps.semantic-version.outputs.semantic_lastRelease_channel }} echo ${{ steps.semantic-version.outputs.semantic_lastRelease_gitTag }} + - name: Update Application Version + run: ./update-version.sh ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: '🔧 chore(release): ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} [skip ci]' + file_pattern: '**/Directory.Packages.props' + disable_globbing: true + - name: Login to DockerHub uses: docker/login-action@v2 with: @@ -45,15 +54,15 @@ jobs: - name: Build image run: | - docker build -t meysamh66/booking-microservices-flight:latest -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . - docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . - docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . - docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . + docker build -t meysamh66/booking-microservices-flight:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . + docker build -t meysamh66/booking-microservices-identity:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . + docker build -t meysamh66/booking-microservices-passenger:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . + docker build -t meysamh66/booking-microservices-booking:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - name: Publish image run: | - docker push meysamh66/booking-microservices-flight:latest - docker push meysamh66/booking-microservices-identity:latest - docker push meysamh66/booking-microservices-passenger:latest - docker push meysamh66/booking-microservices-booking:latest + docker push meysamh66/booking-microservices-flight:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} + docker push meysamh66/booking-microservices-identity:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} + docker push meysamh66/booking-microservices-passenger:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} + docker push meysamh66/booking-microservices-booking:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} diff --git a/update-version.sh b/update-version.sh new file mode 100644 index 0000000..28c6f73 --- /dev/null +++ b/update-version.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# update package version and version for in the csproj file to new version and commit it again with using https://github.com/semantic-release/git plugin +# https://unix.stackexchange.com/questions/50313/how-do-i-perform-an-action-on-all-files-with-a-specific-extension-in-subfolders +find . -name '*.Packages.props' -exec sed -i "s#.*#$1#" {} \; -exec cat {} \; +find . -name '*.Packages.props' -exec sed -i "s#.*#$1#" {} \; -exec cat {} \; +find . -name '*.Packages.props' -exec sed -i "s#.*#$1#" {} \; -exec cat {} \; From 50c9998056d598970a2b66f63fcdb5ee3aab8d6e Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:06:55 +0330 Subject: [PATCH 02/17] . --- .github/workflows/build-publish-docker.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index a5634c9..4954269 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -24,8 +24,6 @@ jobs: id: semantic-version env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # because of using none default (conventionalcommits) `preset` for `semantic-release`, we should add dependency `conventional-changelog-conventionalcommits` - # using dry-run here for preventing publish release note and just calculate version run: npx -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/exec semantic-release --dry-run - name: Semantic Release Versions Outputs From a50e008c2319d7c517a86a17389591f73f46b1cf Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:15:56 +0330 Subject: [PATCH 03/17] . --- .github/workflows/build-publish-docker.yml | 49 ++++++---------------- update-version.sh | 7 ---- 2 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 update-version.sh diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 4954269..3166612 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -15,35 +15,10 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 'lts/*' - - - name: Semantic Release Version - id: semantic-version - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npx -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/exec semantic-release --dry-run - - - name: Semantic Release Versions Outputs - run: | - echo ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} - echo ${{ steps.semantic-version.outputs.semantic_nextRelease_channel }} - echo ${{ steps.semantic-version.outputs.semantic_nextRelease_gitTag }} - echo ${{ steps.semantic-version.outputs.semantic_lastRelease_version }} - echo ${{ steps.semantic-version.outputs.semantic_lastRelease_channel }} - echo ${{ steps.semantic-version.outputs.semantic_lastRelease_gitTag }} - - - name: Update Application Version - run: ./update-version.sh ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: '🔧 chore(release): ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} [skip ci]' - file_pattern: '**/Directory.Packages.props' - disable_globbing: true - + - id: version + uses: battila7/get-version-action@v2 + - name: Add Semantic Version tag to Docker Image + uses: shrink/actions-docker-registry-tag@v3 - name: Login to DockerHub uses: docker/login-action@v2 with: @@ -52,15 +27,15 @@ jobs: - name: Build image run: | - docker build -t meysamh66/booking-microservices-flight:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . - docker build -t meysamh66/booking-microservices-identity:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . - docker build -t meysamh66/booking-microservices-passenger:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . - docker build -t meysamh66/booking-microservices-booking:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . + docker build -t meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . + docker build -t meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . + docker build -t meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . + docker build -t meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - name: Publish image run: | - docker push meysamh66/booking-microservices-flight:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} - docker push meysamh66/booking-microservices-identity:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} - docker push meysamh66/booking-microservices-passenger:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} - docker push meysamh66/booking-microservices-booking:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} + docker push meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} + docker push meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} + docker push meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} + docker push meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} diff --git a/update-version.sh b/update-version.sh deleted file mode 100644 index 28c6f73..0000000 --- a/update-version.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# update package version and version for in the csproj file to new version and commit it again with using https://github.com/semantic-release/git plugin -# https://unix.stackexchange.com/questions/50313/how-do-i-perform-an-action-on-all-files-with-a-specific-extension-in-subfolders -find . -name '*.Packages.props' -exec sed -i "s#.*#$1#" {} \; -exec cat {} \; -find . -name '*.Packages.props' -exec sed -i "s#.*#$1#" {} \; -exec cat {} \; -find . -name '*.Packages.props' -exec sed -i "s#.*#$1#" {} \; -exec cat {} \; From 26b9429df1316b8b14852fb0eb95e2e3498300a1 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:17:14 +0330 Subject: [PATCH 04/17] . --- .github/workflows/build-publish-docker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 3166612..4d35a9c 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -17,8 +17,7 @@ jobs: - id: version uses: battila7/get-version-action@v2 - - name: Add Semantic Version tag to Docker Image - uses: shrink/actions-docker-registry-tag@v3 + - name: Login to DockerHub uses: docker/login-action@v2 with: From 33be997855495ec52230ca41caef79c5a45ddbbd Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:35:39 +0330 Subject: [PATCH 05/17] . --- .github/workflows/build-publish-docker.yml | 51 +++++++++++++++------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 4d35a9c..2eb3a42 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -3,6 +3,8 @@ name: build-publish-docker on: push: branches: [ develop ] + tags: + - 'v*' pull_request: jobs: @@ -12,11 +14,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - - id: version - uses: battila7/get-version-action@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/thedatabaseme/hello-world + flavor: latest=true + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} - name: Login to DockerHub uses: docker/login-action@v2 @@ -24,17 +33,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build image - run: | - docker build -t meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . - docker build -t meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . - docker build -t meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . - docker build -t meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + file: ./src/Services/Flight/Dockerfile + push: ${{ github.ref_type == 'tag' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - - name: Publish image - run: | - docker push meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} - docker push meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} - docker push meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} - docker push meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} + +# - name: Build image +# run: | +# docker build -t meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . +# docker build -t meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . +# docker build -t meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . +# docker build -t meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . +# +# - name: Publish image +# run: | +# docker push meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} +# docker push meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} +# docker push meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} +# docker push meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} From 64b1c219ab1f3c75e770827c81bd880cff826a25 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:41:29 +0330 Subject: [PATCH 06/17] . --- .github/workflows/build-publish-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 2eb3a42..dc8bf42 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -38,8 +38,8 @@ jobs: with: context: . file: ./src/Services/Flight/Dockerfile - push: ${{ github.ref_type == 'tag' }} - tags: ${{ steps.meta.outputs.tags }} + push: true + tags: meysamh66/booking-microservices-flight:${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 5d6ce44e898882647fd75e332c5a32e837d98700 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:44:17 +0330 Subject: [PATCH 07/17] . --- .github/workflows/build-publish-docker.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index dc8bf42..e8c2907 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -33,14 +33,18 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build and push uses: docker/build-push-action@v3 with: context: . file: ./src/Services/Flight/Dockerfile push: true - tags: meysamh66/booking-microservices-flight:${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:latest +# meysamh66/booking-microservices-flight:${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} # - name: Build image From d069af0ef272b2aed571f192751df21147027df3 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:46:49 +0330 Subject: [PATCH 08/17] . --- .github/workflows/build-publish-docker.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index e8c2907..75e165e 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -42,9 +42,8 @@ jobs: context: . file: ./src/Services/Flight/Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:latest -# meysamh66/booking-microservices-flight:${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} + tags: ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} # - name: Build image From 2b330f77a4ca821b0b9f1b4dca9f48d869601a5a Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:52:03 +0330 Subject: [PATCH 09/17] . --- .github/workflows/build-publish-docker.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 75e165e..74904c2 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -28,22 +28,23 @@ jobs: type=semver,pattern={{version}} - name: Login to DockerHub + if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v2 - name: Build and push uses: docker/build-push-action@v3 with: context: . file: ./src/Services/Flight/Dockerfile - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} + labels: ${{ steps.meta.outputs.labels }} # - name: Build image From 214ddd325e262b25390234a21bed5d57941a45ce Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 03:55:10 +0330 Subject: [PATCH 10/17] . --- .github/workflows/build-publish-docker.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 74904c2..12d3d96 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -20,7 +20,6 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/thedatabaseme/hello-world flavor: latest=true tags: | type=ref,event=branch @@ -28,21 +27,20 @@ jobs: type=semver,pattern={{version}} - name: Login to DockerHub - if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Build and push uses: docker/build-push-action@v3 with: context: . file: ./src/Services/Flight/Dockerfile - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From f9780be574fd524a8d9e79e38410d5dea832e9aa Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 04:10:35 +0330 Subject: [PATCH 11/17] . --- .github/workflows/build-publish-docker.yml | 40 ++++++---------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 12d3d96..4535d8f 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -3,8 +3,6 @@ name: build-publish-docker on: push: branches: [ develop ] - tags: - - 'v*' pull_request: jobs: @@ -16,16 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - flavor: latest=true - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - - name: Login to DockerHub uses: docker/login-action@v2 with: @@ -39,23 +27,15 @@ jobs: uses: docker/build-push-action@v3 with: context: . - file: ./src/Services/Flight/Dockerfile + file: | + ./src/Services/Flight/Dockerfile + ./src/Services/Identity/Dockerfile + ./src/Services/Passenger/Dockerfile + ./src/Services/Booking/Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - -# - name: Build image -# run: | -# docker build -t meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . -# docker build -t meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . -# docker build -t meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . -# docker build -t meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . -# -# - name: Publish image -# run: | -# docker push meysamh66/booking-microservices-flight:${{ steps.version.outputs.version }} -# docker push meysamh66/booking-microservices-identity:${{ steps.version.outputs.version }} -# docker push meysamh66/booking-microservices-passenger:${{ steps.version.outputs.version }} -# docker push meysamh66/booking-microservices-booking:${{ steps.version.outputs.version }} + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:latest + ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:latest + ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:latest + ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:latest From 80c6e143f0eb4628756fbf1da9dbd5583e5ee90c Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 04:17:27 +0330 Subject: [PATCH 12/17] . --- .github/workflows/build-publish-docker.yml | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 4535d8f..89390ac 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -20,22 +20,17 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Build image + run: | + docker build -t meysamh66/booking-microservices-flight:latest -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . + docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . + docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . + docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: | - ./src/Services/Flight/Dockerfile - ./src/Services/Identity/Dockerfile - ./src/Services/Passenger/Dockerfile - ./src/Services/Booking/Dockerfile - push: true - tags: | - ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:latest - ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:latest - ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:latest - ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:latest + - name: Publish image + run: | + docker push meysamh66/booking-microservices-flight:latest + docker push meysamh66/booking-microservices-identity:latest + docker push meysamh66/booking-microservices-passenger:latest + docker push meysamh66/booking-microservices-booking:latest From cf119a9d9e71d4bdb49ea55e0ac85ccbb1346740 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 15:00:52 +0330 Subject: [PATCH 13/17] . --- .github/workflows/build-publish-docker.yml | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 89390ac..36805e9 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -13,6 +13,17 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - + - uses: salsify/action-detect-and-tag-new-version@v2 + with: + version-command: | + cat current-version.txt + + - name: Versions Outputs + run: | + echo v{VERSION} - name: Login to DockerHub uses: docker/login-action@v2 @@ -23,14 +34,14 @@ jobs: - name: Build image run: | docker build -t meysamh66/booking-microservices-flight:latest -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . - docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . - docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . - docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . +# docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . +# docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . +# docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - name: Publish image run: | docker push meysamh66/booking-microservices-flight:latest - docker push meysamh66/booking-microservices-identity:latest - docker push meysamh66/booking-microservices-passenger:latest - docker push meysamh66/booking-microservices-booking:latest +# docker push meysamh66/booking-microservices-identity:latest +# docker push meysamh66/booking-microservices-passenger:latest +# docker push meysamh66/booking-microservices-booking:latest From b65ae47130a5cdf89bfcf6dbada5ee85b9cc07c4 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 15:07:07 +0330 Subject: [PATCH 14/17] . --- package.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..d1992e2 --- /dev/null +++ b/package.json @@ -0,0 +1,3 @@ +{ + "version": "0.0.0" +} From 28cd15d2f5847d9b38a529a7b75168108dc9b713 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 15:08:23 +0330 Subject: [PATCH 15/17] . --- current-version.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 current-version.txt diff --git a/current-version.txt b/current-version.txt new file mode 100644 index 0000000..e69de29 From 46202f153e964b6a8ba0d4a0fda471c2c4758748 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 15:09:42 +0330 Subject: [PATCH 16/17] . --- .github/workflows/build-publish-docker.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 36805e9..8956330 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -17,9 +17,6 @@ jobs: fetch-depth: 2 - - uses: salsify/action-detect-and-tag-new-version@v2 - with: - version-command: | - cat current-version.txt - name: Versions Outputs run: | From 8b2a951bd9f9aec3be1dd9838b07961c82a22814 Mon Sep 17 00:00:00 2001 From: meysamhadeli Date: Wed, 25 Jan 2023 23:39:02 +0330 Subject: [PATCH 17/17] ci: Add docker to ci --- .github/workflows/build-publish-docker.yml | 44 ------------ .github/workflows/ci.yml | 70 +++++++++++++++++++ .github/workflows/dotnet.yml | 42 ----------- .github/workflows/release-drafter.yml | 18 ----- .../Data/DesignTimeDbContextFactory.cs | 2 +- .../Data/PersistMessageDbContext.cs | 16 ++--- 6 files changed, 77 insertions(+), 115 deletions(-) delete mode 100644 .github/workflows/build-publish-docker.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/dotnet.yml delete mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml deleted file mode 100644 index 8956330..0000000 --- a/.github/workflows/build-publish-docker.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: build-publish-docker - -on: - push: - branches: [ develop ] - pull_request: - -jobs: - - build-and-push-docker-image: - name: Build and Publish Docker image to DockerHub - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 2 - - - - uses: salsify/action-detect-and-tag-new-version@v2 - - - name: Versions Outputs - run: | - echo v{VERSION} - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build image - run: | - docker build -t meysamh66/booking-microservices-flight:latest -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . -# docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . -# docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . -# docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . - - - name: Publish image - run: | - docker push meysamh66/booking-microservices-flight:latest -# docker push meysamh66/booking-microservices-identity:latest -# docker push meysamh66/booking-microservices-passenger:latest -# docker push meysamh66/booking-microservices-booking:latest - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..26a28ec --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +name: CI + +on: + push: + branches: [ "main" , "develop" ] + paths-ignore: + - "README.md" + pull_request: + branches: [ "main" , "develop" ] + paths-ignore: + - "README.md" + +jobs: + build: + runs-on: ubuntu-latest + + 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: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore + + - 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 + if: github.ref == 'refs/heads/main' + 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 + - name: Build Docker Image + if: 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" . + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . + 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' + 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 }} + docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:${{ steps.last_release.outputs.tag_name }} + docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }} + diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml deleted file mode 100644 index 9d6567a..0000000 --- a/.github/workflows/dotnet.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build-Test - -on: - push: - branches: [ "main" , "develop" ] - paths-ignore: - - "README.md" - pull_request: - branches: [ "main" , "develop" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 'lts/*' - - - name: Cache NuGet Packages - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-dotnet-nuget - path: ~/.nuget/packages - - - name: Restore dependencies - run: dotnet restore - - - name: Build - run: dotnet build -c Release --no-restore - - - name: Test - run: dotnet test -c Release --no-restore - diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml deleted file mode 100644 index 98af17d..0000000 --- a/.github/workflows/release-drafter.yml +++ /dev/null @@ -1,18 +0,0 @@ - # https://johanneskonings.dev/github/2021/02/28/github_automatic_releases_and-changelog/ - # https://tiagomichaelsousa.dev/articles/stop-writing-your-changelogs-manually - name: Release Drafter - - on: - push: - branches: - - main - jobs: - update_release_draft: - name: Release drafter - runs-on: ubuntu-latest - - steps: - - name: Update Release Draft - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/BuildingBlocks/PersistMessageProcessor/Data/DesignTimeDbContextFactory.cs b/src/BuildingBlocks/PersistMessageProcessor/Data/DesignTimeDbContextFactory.cs index 5609afe..ce710a6 100644 --- a/src/BuildingBlocks/PersistMessageProcessor/Data/DesignTimeDbContextFactory.cs +++ b/src/BuildingBlocks/PersistMessageProcessor/Data/DesignTimeDbContextFactory.cs @@ -11,6 +11,6 @@ public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory> _logger; + private readonly ILogger _logger; - public PersistMessageDbContext(DbContextOptions options) + public PersistMessageDbContext(DbContextOptions options, + ILogger logger) : base(options) { - _logger = new Lazy>(() => - { - var factory = LoggerFactory.Create(b => b.AddConsole()); - var logger = factory.CreateLogger(); - return logger; - }); + _logger = logger; } public DbSet PersistMessages => Set(); @@ -45,7 +41,7 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext { if (exception != null) { - _logger.Value.LogError(exception, + _logger.LogError(exception, "Request failed with {StatusCode}. Waiting {TimeSpan} before next retry. Retry attempt {RetryCount}.", HttpStatusCode.Conflict, timeSpan, @@ -63,7 +59,7 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext var currentValue = entry.Entity; // we can use it for specific merging var databaseValue = await entry.GetDatabaseValuesAsync(cancellationToken); - _logger.Value.LogInformation( + _logger.LogInformation( "Entry to entity with type: {Type}, database-value: {DatabaseValue} and current-value: {CurrentValue}", entry.GetType().Name, databaseValue,