Skip to content

Commit

Permalink
fix: multiple container tag issue fix (#1552)
Browse files Browse the repository at this point in the history
Co-authored-by: Roopan-Microsoft <168007406+Roopan-Microsoft@users.noreply.github.com>
  • Loading branch information
AjitPadhi-Microsoft and Roopan-Microsoft authored Dec 9, 2024
1 parent e5cf4dd commit 02d0056
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 205 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: Build Docker Images

on:
workflow_run:
workflows: [Tests]
types: [completed]
branches: [main, dev, demo]
push:
branches:
- main
- dev
- demo
pull_request:
branches: [main, dev, demo]
branches:
- main
- dev
- demo
types:
- opened
- ready_for_review
Expand All @@ -16,7 +20,6 @@ on:

jobs:
docker-build:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
strategy:
matrix:
include:
Expand All @@ -28,10 +31,10 @@ jobs:
dockerfile: docker/Frontend.Dockerfile
uses: ./.github/workflows/build-docker.yml
with:
registry: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic.azurecr.io' || 'cwydcontainerreg.azurecr.io'}}
username: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic' || 'cwydcontainerreg'}}
registry: ${{ github.ref_name == 'main' && 'fruoccopublic.azurecr.io' || 'cwydcontainerreg.azurecr.io'}}
username: ${{ github.ref_name == 'main' && 'fruoccopublic' || 'cwydcontainerreg'}}
app_name: ${{ matrix.app_name }}
dockerfile: ${{ matrix.dockerfile }}
branch: ${{ github.event.workflow_run.head_branch }}
push: ${{ github.event_name == 'workflow_run' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'dev' || github.event.workflow_run.head_branch == 'demo') }}
branch: ${{ github.ref_name }}
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }}
secrets: inherit
18 changes: 4 additions & 14 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ on:
dockerfile:
required: true
type: string
branch:
required: true
type: string
push:
required: true
type: boolean
Expand All @@ -31,26 +28,19 @@ jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- name: Print target branch detail
run: |
echo "Target branch:" ${{ inputs.branch }}
echo "Target branch status:" ${{ inputs.push }}
echo "Target registry status:" ${{ inputs.registry }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}

- name: Docker Login
if: ${{ inputs.push == true && inputs.branch == 'main' }}
if: ${{ inputs.push == true && github.ref_name == 'main' }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Dev Docker Login
if: ${{ inputs.push == true && (inputs.branch == 'dev' || inputs.branch == 'demo') }}
if: ${{ inputs.push == true && (github.ref_name == 'dev' || github.ref_name == 'demo') }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
Expand All @@ -70,7 +60,7 @@ jobs:
context: .
file: ${{ inputs.dockerfile }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ inputs.branch == 'main' && 'latest' || inputs.branch == 'dev' && 'dev' || inputs.branch == 'demo' && 'demo' || 'latest' }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref }}
tags: |
${{ inputs.registry }}/${{ inputs.app_name}}:${{ inputs.branch == 'main' && 'latest' || inputs.branch == 'dev' && 'dev' || inputs.branch == 'demo' && 'demo' || 'latest' }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
env:
AZURE_ENV_NAME: ${{ github.run_id }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
with:
imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
cacheFrom: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
Expand All @@ -66,15 +65,12 @@ jobs:
AZURE_SUBSCRIPTION_ID
AZURE_ENV_NAME
AZURE_LOCATION
AZURE_RESOURCE_GROUP
- name: Tidy up
uses: devcontainers/ci@v0.3
if: always()
env:
AZURE_ENV_NAME: ${{ github.run_id }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
with:
push: never
imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
Expand All @@ -87,8 +83,7 @@ jobs:
AZURE_SUBSCRIPTION_ID
AZURE_ENV_NAME
AZURE_LOCATION
AZURE_RESOURCE_GROUP
- name: Send Notification on Failure
if: failure()
run: |
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,10 @@ azd-login: ## 🔑 Login to Azure with azd and a SPN
@echo -e "\e[34m$@\e[0m" || true
@azd auth login --client-id ${AZURE_CLIENT_ID} --client-secret ${AZURE_CLIENT_SECRET} --tenant-id ${AZURE_TENANT_ID}

az-login: ## 🔑 Login to Azure with az and a SPN
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID}

deploy: azd-login az-login ## 🚀 Deploy everything to Azure
deploy: azd-login ## 🚀 Deploy everything to Azure
@echo -e "\e[34m$@\e[0m" || true
@azd env new ${AZURE_ENV_NAME}
@azd env set AZURE_APP_SERVICE_HOSTING_MODEL code --no-prompt
@az group create --name ${AZURE_RESOURCE_GROUP} --location ${AZURE_LOCATION}
@azd provision --no-prompt
@azd deploy web --no-prompt
@azd deploy function --no-prompt
Expand Down
2 changes: 1 addition & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ param principalId string = ''
'rbac'
'keys'
])
param authType string = 'keys'
param authType string = 'rbac'

@description('Hosting model for the web apps. Containers are prebuilt and can be deployed faster, but code allows for more customization.')
@allowed([
Expand Down
Loading

0 comments on commit 02d0056

Please sign in to comment.