-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (62 loc) · 2.54 KB
/
Copy pathdeploy_to_aci.yml
File metadata and controls
72 lines (62 loc) · 2.54 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
# This workflow will build and deploy an application to Azure Container Instances (ACI)
# It uses the same container registry as the AKS deployment workflow
name: Deploy to ACI
on:
workflow_dispatch:
env:
AZURE_CONTAINER_REGISTRY: "jaz400acr"
CONTAINER_NAME: "docker-app"
RESOURCE_GROUP: "az400"
ACI_NAME: "docker-app-aci"
jobs:
buildAndDeploy:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
environment: production
steps:
# Checks out the repository this file is in
- uses: actions/checkout@v4
# Logs in with your Azure credentials
- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
# Deploy ACR using Bicep if it doesn't exist
- name: Deploy ACR using Bicep
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ env.RESOURCE_GROUP }}
template: azd/aci/modules/acr.bicep
parameters: "registryName=${{ env.AZURE_CONTAINER_REGISTRY }}"
failOnStdErr: false
# Builds and pushes an image up to your Azure Container Registry
- name: Build and push image to ACR
run: |
az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:latest --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} .
# Deploy to ACI using Bicep
- name: Deploy to Azure Container Instances
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ env.RESOURCE_GROUP }}
template: IaC/aci.bicep
parameters: >
containerInstanceName=${{ env.ACI_NAME }}
acrName=${{ env.AZURE_CONTAINER_REGISTRY }}
imageName=${{ env.CONTAINER_NAME }}
failOnStdErr: false
# Get ACI IP address for output
- name: Get ACI IP Address
id: get-aci-ip
run: |
IP_ADDRESS=$(az container show --name ${{ env.ACI_NAME }} --resource-group ${{ env.RESOURCE_GROUP }} --query ipAddress.ip -o tsv)
echo "Container is accessible at: http://$IP_ADDRESS"
echo "ACI_IP=$IP_ADDRESS" >> $GITHUB_OUTPUT
- name: Output deployment URL
run: echo "Application deployed to http://${{ steps.get-aci-ip.outputs.ACI_IP }}"