-
Notifications
You must be signed in to change notification settings - Fork 2
84 lines (71 loc) · 3.41 KB
/
simulator-deploy.yml
File metadata and controls
84 lines (71 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Build and Deploy Robot Simulator
on:
push:
branches: [main]
paths:
- "RobotSimulator/**"
# Required for OIDC federated identity authentication — no client secrets used
permissions:
id-token: write
contents: read
env:
RESOURCE_GROUP: ewu-deliverybotsystem-rg
# ACR — pre-created; admin credentials stored as Container App registry secret
ACR_NAME: DeliverybotCR
ACR_LOGIN_SERVER: deliverybotcr.azurecr.io
# Container App — pre-created with system-assigned managed identity
CONTAINER_APP_NAME: deliverybot-robot-simulator
IMAGE_NAME: deliverybot-robot-simulator
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# ── 1. Checkout source code ───────────────────────────────────────────────
- name: Checkout repository
uses: actions/checkout@v4
# ── 2. Authenticate to Azure via OIDC federated identity ─────────────────
- name: Azure Login (OIDC)
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# ── 3. Build Docker image and push to ACR ────────────────────────────────
# Build context is RobotSimulator/ to match the docker-compose convention.
# The Dockerfile copies src projects relative to that context root.
- name: Log in to Azure Container Registry
run: az acr login --name "$ACR_NAME"
- name: Build and push Docker image
run: |
IMAGE_TAG="${ACR_LOGIN_SERVER}/${IMAGE_NAME}:${{ github.sha }}"
echo "Building: $IMAGE_TAG"
docker build \
-f RobotSimulator/src/DeliveryBot.RobotSimulator.Api/Dockerfile \
-t "$IMAGE_TAG" \
RobotSimulator/
docker push "$IMAGE_TAG"
echo "IMAGE_TAG=$IMAGE_TAG" >> "$GITHUB_ENV"
# ── 4. Deploy updated image to Container App ─────────────────────────────
# Image-only update — environment variables and secrets already configured
# on the live Container App are intentionally left unchanged.
# Do not add --set-env-vars here; Event Hub transport settings are managed
# outside this workflow until they are brought under IaC.
- name: Update Container App image
run: |
az containerapp update \
--name "$CONTAINER_APP_NAME" \
--resource-group "$RESOURCE_GROUP" \
--image "$IMAGE_TAG"
# ── 5. Output the live deployment URL ─────────────────────────────────────
- name: Print deployment URL
run: |
FQDN=$(az containerapp show \
--name "$CONTAINER_APP_NAME" \
--resource-group "$RESOURCE_GROUP" \
--query properties.configuration.ingress.fqdn -o tsv)
echo "========================================"
echo " Deployment complete!"
echo " App URL : https://${FQDN}"
echo " Health : https://${FQDN}/health"
echo " Bots API : https://${FQDN}/bots"
echo "========================================"