1414 REGISTRY : ghcr.io
1515
1616jobs :
17- build-backend :
17+ build-and-push :
1818 runs-on : ubuntu-latest
1919 permissions :
2020 contents : read
2121 packages : write
2222
23- steps :
24- - name : Checkout repository
25- uses : actions/checkout@v4
26-
27- - name : Set up QEMU (for multi-platform builds)
28- uses : docker/setup-qemu-action@v3
29-
30- - name : Set up Docker Buildx
31- uses : docker/setup-buildx-action@v3
32-
33- - name : Log in to GHCR
34- uses : docker/login-action@v3
35- with :
36- registry : ${{ env.REGISTRY }}
37- username : ${{ github.actor }}
38- password : ${{ secrets.GITHUB_TOKEN }}
39-
40- - name : Extract metadata
41- id : meta
42- uses : docker/metadata-action@v5
43- with :
44- images : ${{ env.REGISTRY }}/zipstack/visitran-backend
45- tags : |
46- type=semver,pattern={{version}}
47- type=semver,pattern={{major}}.{{minor}}
48- type=raw,value=latest,enable={{is_default_branch}}
49- type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
50-
51- - name : Build and push backend
52- uses : docker/build-push-action@v6
53- with :
54- context : .
55- file : docker/dockerfiles/backend.Dockerfile
56- platforms : linux/amd64,linux/arm64
57- push : true
58- tags : ${{ steps.meta.outputs.tags }}
59- labels : ${{ steps.meta.outputs.labels }}
60- cache-from : type=gha
61- cache-to : type=gha,mode=max
62-
63- build-frontend :
64- runs-on : ubuntu-latest
65- permissions :
66- contents : read
67- packages : write
23+ strategy :
24+ matrix :
25+ include :
26+ - image : backend
27+ dockerfile : docker/dockerfiles/backend.Dockerfile
28+ - image : frontend
29+ dockerfile : docker/dockerfiles/frontend.Dockerfile
6830
6931 steps :
7032 - name : Checkout repository
7133 uses : actions/checkout@v4
34+ with :
35+ ref : ${{ github.event.release.tag_name || github.event.inputs.tag }}
7236
7337 - name : Set up QEMU (for multi-platform builds)
7438 uses : docker/setup-qemu-action@v3
@@ -83,25 +47,29 @@ jobs:
8347 username : ${{ github.actor }}
8448 password : ${{ secrets.GITHUB_TOKEN }}
8549
50+ - name : Set image prefix
51+ id : repo
52+ run : echo "image_prefix=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
53+
8654 - name : Extract metadata
8755 id : meta
8856 uses : docker/metadata-action@v5
8957 with :
90- images : ${{ env.REGISTRY }}/zipstack/visitran-frontend
58+ images : ${{ steps.repo.outputs.image_prefix }}/${{ matrix.image }}
9159 tags : |
9260 type=semver,pattern={{version}}
9361 type=semver,pattern={{major}}.{{minor}}
94- type=raw,value=latest,enable={{is_default_branch }}
62+ type=raw,value=latest,enable=${{ github.event_name == 'release' }}
9563 type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
9664
97- - name : Build and push frontend
65+ - name : Build and push ${{ matrix.image }}
9866 uses : docker/build-push-action@v6
9967 with :
10068 context : .
101- file : docker/dockerfiles/frontend.Dockerfile
69+ file : ${{ matrix.dockerfile }}
10270 platforms : linux/amd64,linux/arm64
10371 push : true
10472 tags : ${{ steps.meta.outputs.tags }}
10573 labels : ${{ steps.meta.outputs.labels }}
106- cache-from : type=gha
107- cache-to : type=gha,mode=max
74+ cache-from : type=gha,scope=${{ matrix.image }}
75+ cache-to : type=gha,mode=max,scope=${{ matrix.image }}
0 commit comments