diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..c3ceee2 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,55 @@ +name: Build & Push Images (main) + +on: + push: + branches: [main] + workflow_dispatch: + +env: + IMAGE_TAG: ${{ github.sha }}-${{ github.run_number }} + +concurrency: + group: deploy-main + cancel-in-progress: true + +jobs: + build_and_push: + runs-on: ubuntu-latest + environment: prod + + strategy: + matrix: + include: + - name: product-service + context: example-1/backend/product_Service + - name: frontend + context: example-1/frontend + + steps: + - name: Checkout + uses: actions/checkout@v4 + + # Log in to Azure (so az is authenticated if you ever need it) + - name: Azure login + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + # Docker login to your ACR (REPLACES `az acr login`) + - name: Login to ACR + uses: docker/login-action@v3 + with: + registry: ${{ vars.ACR_LOGIN_SERVER }} + username: ${{ fromJSON(secrets.AZURE_CREDENTIALS).clientId }} + password: ${{ fromJSON(secrets.AZURE_CREDENTIALS).clientSecret }} + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build & Push ${{ matrix.name }} + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.context }} + push: true + tags: ${{ vars.ACR_LOGIN_SERVER }}/${{ matrix.name }}:${{ env.IMAGE_TAG }} + diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml new file mode 100644 index 0000000..e179b7d --- /dev/null +++ b/.github/workflows/pr-ci.yml @@ -0,0 +1,13 @@ +name: PR CI (basic) + +on: + pull_request: + branches: [dev, main] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + run-ci: + uses: ./.github/workflows/reusable-ci.yml diff --git a/.github/workflows/reusable-ci.yml b/.github/workflows/reusable-ci.yml new file mode 100644 index 0000000..7d17864 --- /dev/null +++ b/.github/workflows/reusable-ci.yml @@ -0,0 +1,13 @@ +name: reusable-ci (basic) + +on: + workflow_call: + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Sanity check + run: | + echo "✅ Reusable CI ran on $GITHUB_REF from $GITHUB_REPOSITORY" diff --git a/example-3/k8s/order-service.yaml b/example-3/k8s/order-service.yaml index 867a015..aa51693 100644 --- a/example-3/k8s/order-service.yaml +++ b/example-3/k8s/order-service.yaml @@ -22,7 +22,7 @@ spec: spec: containers: - name: order-service-container - image: /order:latest + image: himanshudhakaw09acr10504.azurecr.io/backend-order:week09 imagePullPolicy: Always ports: - containerPort: 8001 diff --git a/example-3/k8s/product-service.yaml b/example-3/k8s/product-service.yaml index 52c7c28..aed8f79 100644 --- a/example-3/k8s/product-service.yaml +++ b/example-3/k8s/product-service.yaml @@ -22,7 +22,7 @@ spec: spec: containers: - name: product-service-container - image: AZURE_CONTAINER_REGISTRY/product_service:latest + image: himanshudhakaw09acr10504.azurecr.io/backend-product:week09 imagePullPolicy: Always ports: - containerPort: 8000