-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (86 loc) · 2.6 KB
/
cd-ui.yaml
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
name: CD - UI
on:
push:
branches: [ main ]
paths:
- ui/**
pull_request:
branches: [ main ]
paths:
- ui/**
workflow_dispatch:
env:
DOCKER_REPO: lwitkowski.azurecr.io
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
echo "DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-ui:${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup node_modules cache
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: 'Install dependencies'
working-directory: ./ui
run: npm install
- name: 'Static analysis (esLint) and formatting checks'
working-directory: ./ui
run: npm run lint
- name: 'Run tests'
working-directory: ./ui
run: CI=true npm run test:unit
- name: 'Build VueJS app'
working-directory: ./ui
run: npm run build
- name: 'Build docker image'
working-directory: ./ui
run: |
docker build . -t ${DOCKER_IMAGE}
- name: 'Login to ACR'
uses: azure/docker-login@v2
if: github.ref == 'refs/heads/main'
with:
login-server: ${{ env.DOCKER_REPO }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: 'Push image to ACR'
if: github.ref == 'refs/heads/main'
run: |
docker push ${DOCKER_IMAGE}
# only for main builds, and only if both components get built correctly
deploy:
runs-on: ubuntu-latest
environment: production
if: github.ref == 'refs/heads/main'
needs:
- build
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- run: |
echo "DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-ui:${GITHUB_SHA::7}" >> $GITHUB_ENV
- 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 }}
- name: 'Deploy to Azure'
uses: azure/container-apps-deploy-action@v2
with:
resourceGroup: rg-aerooffers
containerAppEnvironment: cae-aerooffers-prod
containerAppName: ca-aerooffers-ui
imageToDeploy: ${{ env.DOCKER_IMAGE }}
disableTelemetry: true