-
Notifications
You must be signed in to change notification settings - Fork 99
108 lines (96 loc) · 4.59 KB
/
docker-build.yml
File metadata and controls
108 lines (96 loc) · 4.59 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Build Docker and Optional Push - Agentic Applications for Unified Data Foundation
on:
push:
branches:
- main
- dev
- demo
paths:
- 'src/App/**'
- 'src/api/**'
- '.github/workflows/docker-build.yml'
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
branches:
- main
- dev
- demo
paths:
- 'src/App/**'
- 'src/api/**'
- '.github/workflows/docker-build.yml'
workflow_dispatch:
permissions:
contents: read
actions: read
id-token: write
jobs:
build-and-push:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Azure using OIDC
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo')) || (github.event_name == 'workflow_dispatch' && (github.ref_name == 'dependabotchanges'||github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo')) }}
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Log in to Azure Container Registry
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo')) || (github.event_name == 'workflow_dispatch' && (github.ref_name == 'dependabotchanges'||github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo')) }}
run: az acr login --name $(echo "${{ secrets.ACR_LOGIN_SERVER }}" | cut -d'.' -f1)
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Output ACR Login Server
run: |
echo "ACR Login Server: ${{ secrets.ACR_LOGIN_SERVER }}"
- name: Determine Tag Name Based on Branch
id: determine_tag
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "tagname=latest_v2" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == "dev" ]]; then
echo "tagname=dev" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == "demo" ]]; then
echo "tagname=demo" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == "dependabotchanges" ]]; then
echo "tagname=dependabotchanges" >> $GITHUB_OUTPUT
else
echo "tagname=default" >> $GITHUB_OUTPUT
fi
- name: Build and Push Docker Image for WebApp
uses: docker/build-push-action@v6
with:
context: ./src/App
file: ./src/App/WebApp.Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
tags: |
${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}/da-app:${{ steps.determine_tag.outputs.tagname }}
${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}/da-app:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
- name: Build and Push Docker Image for api
uses: docker/build-push-action@v6
with:
context: ./src/api/python
file: ./src/api/python/ApiApp.Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
tags: |
${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}/da-api:${{ steps.determine_tag.outputs.tagname }}
${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}/da-api:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
- name: Build and Push Docker Image for CsApi
uses: docker/build-push-action@v6
with:
context: ./src/api/dotnet
file: ./src/api/dotnet/CsApi.Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
tags: |
${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}/da-api-dotnet:${{ steps.determine_tag.outputs.tagname }}
${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}/da-api-dotnet:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}