1+ name : " Build & Push Docker"
2+
3+ on :
4+ push :
5+ branches :
6+ - next # Next, tags as "next"
7+ - master # Edge, tags as "edge"
8+ - release # Production, tags as "latest"
9+
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref_name }}
12+ cancel-in-progress : true
13+
14+ env :
15+ GHCR_REGISTRY : ghcr.io
16+ GHCR_IMAGE_NAME : ${{ github.repository }}
17+ MANAGED_REGISTRY : registry.digitalocean.com
18+ MANAGED_IMAGE_NAME : manifold/manifold
19+
20+ jobs :
21+ build-api :
22+ runs-on : ubuntu-latest
23+ permissions :
24+ contents : read
25+ packages : write
26+ steps :
27+ - name : Checkout
28+ uses : actions/checkout@v4
29+ - name : Login GHCR
30+ uses : docker/login-action@v4
31+ with :
32+ registry : ${{ env.GHCR_REGISTRY }}
33+ username : ${{ github.actor }}
34+ password : ${{ secrets.GITHUB_TOKEN }}
35+ - name : Login DOCR
36+ uses : docker/login-action@v4
37+ with :
38+ registry : ${{ env.MANAGED_REGISTRY }}
39+ username : docr
40+ password : ${{ secrets.DOCR_TOKEN }}
41+ - name : Docker meta
42+ id : meta
43+ uses : docker/metadata-action@v5
44+ with :
45+ images : |
46+ ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}-api
47+ ${{ env.MANAGED_REGISTRY }}/${{ env.MANAGED_IMAGE_NAME }}-api
48+ tags : |
49+ type=raw,value=latest,enable=${{ github.ref_name == 'release' }}
50+ type=raw,value=edge,enable={{ is_default_branch }}
51+ type=ref,event=branch
52+ - name : Set up Docker Buildx
53+ uses : docker/setup-buildx-action@v3
54+ - name : Build and push Docker
55+ id : push
56+ uses : docker/build-push-action@v5
57+ with :
58+ context : ./api
59+ target : production
60+ push : true
61+ cache-from : type=gha
62+ cache-to : type=gha,mode=max
63+ tags : ${{ steps.meta.outputs.tags }}
64+ labels : ${{ steps.meta.outputs.labels }}
65+ build-args :
66+ " RAILS_ENV=production"
67+
68+ build-client :
69+ runs-on : ubuntu-latest
70+ permissions :
71+ contents : read
72+ packages : write
73+ steps :
74+ - name : Checkout
75+ uses : actions/checkout@v4
76+ - name : Login GHCR
77+ uses : docker/login-action@v4
78+ with :
79+ registry : ${{ env.GHCR_REGISTRY }}
80+ username : ${{ github.actor }}
81+ password : ${{ secrets.GITHUB_TOKEN }}
82+ - name : Login DOCR
83+ uses : docker/login-action@v4
84+ with :
85+ registry : ${{ env.MANAGED_REGISTRY }}
86+ username : docr
87+ password : ${{ secrets.DOCR_TOKEN }}
88+ - name : Docker meta
89+ id : meta
90+ uses : docker/metadata-action@v5
91+ with :
92+ images : |
93+ ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}-client
94+ ${{ env.MANAGED_REGISTRY }}/${{ env.MANAGED_IMAGE_NAME }}-client
95+ tags : |
96+ type=raw,value=latest,enable=${{ github.ref_name == 'release' }}
97+ type=raw,value=edge,enable={{ is_default_branch }}
98+ type=ref,event=branch
99+ - name : Set up Docker Buildx
100+ uses : docker/setup-buildx-action@v3
101+ - name : Build and push Docker
102+ id : push
103+ uses : docker/build-push-action@v5
104+ with :
105+ context : ./client
106+ target : production
107+ push : true
108+ cache-from : type=gha
109+ cache-to : type=gha,mode=max
110+ tags : ${{ steps.meta.outputs.tags }}
111+ labels : ${{ steps.meta.outputs.labels }}
112+ build-args :
113+ " RAILS_ENV=production"
0 commit comments