update to support connection string, try 2 #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This GitHub Actions workflow is designed for the do-solutions/microservices-demo monorepo. | |
| # It automates the building and publishing of Docker images for each microservice to the | |
| # GitHub Container Registry (GHCR). | |
| # | |
| # Key Features: | |
| # - Unified Build Trigger: The workflow runs and builds ALL services if any change is pushed | |
| # to the 'main' branch within the 'src/' or 'helm/' directories. | |
| # - Shared Tagging: All Docker images in a single workflow run are tagged with the same unique, | |
| # time-based version (v1.YYYYMMDD.HHMMSSfff) and 'latest' to ensure version consistency. | |
| # - Helm Chart Publishing: After all images are built, the Helm chart is packaged and published | |
| # as an OCI artifact to GHCR with a version matching the image tags. | |
| name: Build and Publish Services | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'src/**' | |
| - 'helm/**' | |
| jobs: | |
| # This job generates a single, shared image tag for all services in the workflow run. | |
| generate_tag: | |
| name: Generate Shared Image Tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.image_tag.outputs.TAG }} | |
| chart_version: ${{ steps.image_tag.outputs.CHART_VERSION }} | |
| steps: | |
| - name: Generate unique image tag | |
| id: image_tag | |
| run: | | |
| TAG="v1.$(date +'%Y%m%d.%H%M%S%3N')" | |
| echo "TAG=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "CHART_VERSION=${TAG#v}" >> "$GITHUB_OUTPUT" | |
| # The following jobs build and publish each microservice. They all run in parallel | |
| # and use the shared tag generated by the 'generate_tag' job. | |
| adservice: | |
| name: Build and Publish Ad Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: adservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| cartservice: | |
| name: Build and Publish Cart Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: cartservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }}/src | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| checkoutservice: | |
| name: Build and Publish Checkout Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: checkoutservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| currencyservice: | |
| name: Build and Publish Currency Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: currencyservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| emailservice: | |
| name: Build and Publish Email Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: emailservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| frontend: | |
| name: Build and Publish Frontend Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| loadgenerator: | |
| name: Build and Publish Load Generator | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: loadgenerator | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| paymentservice: | |
| name: Build and Publish Payment Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: paymentservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| productcatalogservice: | |
| name: Build and Publish Product Catalog Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: productcatalogservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| recommendationservice: | |
| name: Build and Publish Recommendation Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: recommendationservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| shippingservice: | |
| name: Build and Publish Shipping Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: shippingservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| shoppingassistantservice: | |
| name: Build and Publish Shopping Assistant Service | |
| needs: generate_tag | |
| runs-on: ubuntu-latest | |
| env: | |
| SERVICE_NAME: shoppingassistantservice | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ env.SERVICE_NAME }} | |
| push: true | |
| tags: | | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:${{ needs.generate_tag.outputs.tag }} | |
| ghcr.io/do-solutions/microservices-demo-${{ env.SERVICE_NAME }}:latest | |
| package-and-push-helm-chart: | |
| name: Package and Push Helm Chart | |
| runs-on: ubuntu-latest | |
| needs: | |
| - generate_tag | |
| - adservice | |
| - cartservice | |
| - checkoutservice | |
| - currencyservice | |
| - emailservice | |
| - frontend | |
| - loadgenerator | |
| - paymentservice | |
| - productcatalogservice | |
| - recommendationservice | |
| - shippingservice | |
| - shoppingassistantservice | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: v3.15.2 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Package Helm chart | |
| run: | | |
| helm package ./helm --version ${{ needs.generate_tag.outputs.chart_version }} --app-version ${{ needs.generate_tag.outputs.tag }} | |
| - name: Push Helm chart to GHCR | |
| run: | | |
| helm push microservices-demo-${{ needs.generate_tag.outputs.chart_version }}.tgz oci://ghcr.io/do-solutions |