1+ name : Build & Push Docker images
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ pull_request :
8+ branches :
9+ - master
10+
11+ permissions :
12+ packages : write
13+
14+ jobs :
15+ docker :
16+ runs-on : ubuntu-latest
17+ strategy :
18+ fail-fast : false
19+ matrix :
20+ service :
21+ # Add one entry per microservice
22+ - name : matching-ui
23+ context : ./ui-services/matching-ui-service
24+ - name : questions-ui
25+ context : ./ui-services/question-ui-service
26+ - name : collab-ui
27+ context : ./ui-services/collab-ui-service
28+ - name : user-ui
29+ context : ./ui-services/user-ui-service
30+ - name : history-ui
31+ context : ./ui-services/history-ui-service
32+
33+ steps :
34+ - name : Checkout Repository
35+ uses : actions/checkout@v4
36+
37+ - name : Force owner to lowercase
38+ id : lc
39+ run : echo "value=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
40+
41+ - name : Set up Docker Buildx
42+ uses : docker/setup-buildx-action@v3
43+
44+ - name : Log in to GHCR
45+ if : ${{ github.event_name != 'pull_request' }}
46+ uses : docker/login-action@v3
47+ with :
48+ registry : ghcr.io
49+ username : ${{ steps.lc.outputs.value }}
50+ password : ${{ secrets.GITHUB_TOKEN }}
51+
52+ - name : Extract Docker metadata (tags/labels)
53+ id : meta
54+ uses : docker/metadata-action@v5
55+ with :
56+ images : |
57+ ghcr.io/${{ steps.lc.outputs.value }}/peerprep-${{ matrix.service.name }}
58+ tags : |
59+ type=raw,value=${{ github.sha }}
60+ type=ref,event=branch
61+ type=ref,event=tag
62+ type=raw,value=latest,enable=${{ github.ref_name == 'master' }}
63+
64+ - name : Build (no push for PRs)
65+ if : ${{ github.event_name == 'pull_request' }}
66+ uses : docker/build-push-action@v6
67+ with :
68+ context : ${{ matrix.service.context }}
69+ file : ${{ matrix.service.dockerfile }}
70+ push : false
71+ labels : ${{ steps.meta.outputs.labels }}
72+ cache-from : type=gha
73+ cache-to : type=gha,mode=max
74+
75+ - name : Build & Push
76+ if : ${{ github.event_name != 'pull_request' }}
77+ uses : docker/build-push-action@v6
78+ with :
79+ context : ${{ matrix.service.context }}
80+ file : ${{ matrix.service.dockerfile }}
81+ push : true
82+ tags : ${{ steps.meta.outputs.tags }}
83+ labels : ${{ steps.meta.outputs.labels }}
84+ cache-from : type=gha
85+ cache-to : type=gha,mode=max
86+
0 commit comments