1212 types : [published]
1313 workflow_dispatch :
1414
15+ concurrency :
16+ group : ${{ github.workflow }}-${{ github.ref }}
17+ cancel-in-progress : true
18+
1519env :
1620 REGISTRY : ghcr.io
1721 API_IMAGE : ${{ github.repository }}-api
2024 NEXT_PUBLIC_PORT : 7443
2125
2226jobs :
23- build-and-push :
27+ build-and-push-api :
2428 runs-on : ubuntu-latest
2529 permissions :
2630 contents : read
@@ -33,23 +37,16 @@ jobs:
3337 fetch-depth : 0
3438 ssh-key : ${{ secrets.DEPLOY_KEY }}
3539
36- - name : Create .env files
37- run : |
38- cp .env.sample api/.env
39- cp .env.sample view/.env
40+ - name : Create .env file
41+ run : cp .env.sample api/.env
4042
4143 - name : Set up Docker Buildx
4244 uses : docker/setup-buildx-action@v3
4345 with :
4446 platforms : linux/amd64,linux/arm64
45-
46- - name : Cache Docker layers
47- uses : actions/cache@v4
48- with :
49- path : /tmp/.buildx-cache
50- key : ${{ runner.os }}-buildx-${{ github.sha }}
51- restore-keys : |
52- ${{ runner.os }}-buildx-
47+ driver-opts : |
48+ image=moby/buildkit:latest
49+ network=host
5350
5451 - name : Log in to the Container registry
5552 uses : docker/login-action@v3
@@ -79,13 +76,39 @@ jobs:
7976 labels : ${{ steps.meta-api.outputs.labels }}
8077 build-args : |
8178 API_PORT=${{ env.API_PORT }}
82- cache-from : type=local,src=/tmp/.buildx-cache
83- cache-to : type=local,dest=/tmp/.buildx-cache-new
79+ cache-from : type=registry,ref=${{ env.REGISTRY }}/${{ env.API_IMAGE }}:buildcache
80+ cache-to : type=registry,ref=${{ env.REGISTRY }}/${{ env.API_IMAGE }}:buildcache,mode=max
81+
82+ build-and-push-view :
83+ runs-on : ubuntu-latest
84+ permissions :
85+ contents : read
86+ packages : write
87+
88+ steps :
89+ - name : Checkout repository
90+ uses : actions/checkout@v4
91+ with :
92+ fetch-depth : 0
93+ ssh-key : ${{ secrets.DEPLOY_KEY }}
8494
85- - name : Move cache
86- run : |
87- rm -rf /tmp/.buildx-cache
88- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
95+ - name : Create .env file
96+ run : cp .env.sample view/.env
97+
98+ - name : Set up Docker Buildx
99+ uses : docker/setup-buildx-action@v3
100+ with :
101+ platforms : linux/amd64,linux/arm64
102+ driver-opts : |
103+ image=moby/buildkit:latest
104+ network=host
105+
106+ - name : Log in to the Container registry
107+ uses : docker/login-action@v3
108+ with :
109+ registry : ${{ env.REGISTRY }}
110+ username : ${{ github.actor }}
111+ password : ${{ secrets.GITHUB_TOKEN }}
89112
90113 - name : Extract metadata for View
91114 id : meta-view
@@ -108,10 +131,5 @@ jobs:
108131 labels : ${{ steps.meta-view.outputs.labels }}
109132 build-args : |
110133 NEXT_PUBLIC_PORT=${{ env.NEXT_PUBLIC_PORT }}
111- cache-from : type=local,src=/tmp/.buildx-cache
112- cache-to : type=local,dest=/tmp/.buildx-cache-new
113-
114- - name : Move cache
115- run : |
116- rm -rf /tmp/.buildx-cache
117- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
134+ cache-from : type=registry,ref=${{ env.REGISTRY }}/${{ env.VIEW_IMAGE }}:buildcache
135+ cache-to : type=registry,ref=${{ env.REGISTRY }}/${{ env.VIEW_IMAGE }}:buildcache,mode=max
0 commit comments