-
Notifications
You must be signed in to change notification settings - Fork 64
63 lines (52 loc) · 1.86 KB
/
Copy pathfrontend_ci.yml
File metadata and controls
63 lines (52 loc) · 1.86 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
# week08/.github/workflows/frontend_ci.yml
name: Frontend CI - Build & Push Image
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'frontend/**'
- '.github/workflows/frontend_ci.yml'
# OIDC requires this
permissions:
id-token: write
contents: read
# Global env
env:
# Put login server here, e.g. myregistry.azurecr.io
ACR_LOGIN_SERVER: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
# Unique, traceable tag
IMAGE_TAG: sha-${{ github.sha }}
jobs:
build_and_push_frontend:
runs-on: ubuntu-latest
# IMPORTANT: this must match the environment you used in Azure federated credentials
environment: staging
steps:
- name: Checkout repository
uses: actions/checkout@v4
# OIDC login (no client secret / no creds JSON)
- 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 }}
# Quick sanity: show account (helps with screenshots & debugging)
- name: Sanity check
run: az account show
# ACR login: --name expects the REGISTRY NAME, not the login server
- name: Login to Azure Container Registry
run: |
ACR_NAME="${ACR_LOGIN_SERVER%%.*}" # strip .azurecr.io
az acr login --name "$ACR_NAME"
# Build & push with immutable tag AND latest (optional)
- name: Build and Push Frontend Image
run: |
docker build -t $ACR_LOGIN_SERVER/frontend:${IMAGE_TAG} ./frontend
docker tag $ACR_LOGIN_SERVER/frontend:${IMAGE_TAG} $ACR_LOGIN_SERVER/frontend:latest
docker push $ACR_LOGIN_SERVER/frontend:${IMAGE_TAG}
docker push $ACR_LOGIN_SERVER/frontend:latest
- name: Logout from Azure
if: always()
run: az logout