Skip to content

UI vue app is compiled outside docker build now for better caching and access to git info #3

UI vue app is compiled outside docker build now for better caching and access to git info

UI vue app is compiled outside docker build now for better caching and access to git info #3

Workflow file for this run

name: CD - UI
on:
push:
branches: [ main ]
paths:
- frontend/**
pull_request:
branches: [ main ]
paths:
- frontend/**
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
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: 'Install dependencies'
working-directory: ./frontend
run: npm ci
- name: 'Build UI'
working-directory: ./frontend
run: npm run build
- name: 'Build docker image'
working-directory: ./frontend
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