1+ name : Build & Publish Docker Image
2+ on :
3+ push :
4+ branches :
5+ - main
6+ tags :
7+ - " v*"
8+
9+ env :
10+ RELEASE_VERSION : ${{ github.ref_name }}
11+
12+ jobs :
13+ build-and-publish :
14+ name : Build and Publish Docker Image
15+ runs-on : ubuntu-latest
16+
17+ steps :
18+ - name : Checkout
19+ uses : actions/checkout@v3
20+
21+ - name : Docker meta
22+ id : meta
23+ uses : docker/metadata-action@v4
24+ with :
25+ # list of Docker images to use as base name for tags
26+ images : |
27+ ghcr.io/${{ github.repository_owner }}/semantic-search-api
28+
29+ # generate Docker tags based on the following events/attributes
30+ tags : |
31+ type=schedule
32+ type=ref,event=branch
33+ type=ref,event=pr
34+ type=semver,pattern={{version}}
35+ type=semver,pattern={{major}}.{{minor}}
36+ type=semver,pattern={{major}}
37+ type=sha
38+
39+ - name : Set up Docker Buildx
40+ uses : docker/setup-buildx-action@v3
41+
42+ - name : Login to GitHub Container Registry
43+ uses : docker/login-action@v3
44+ with :
45+ registry : ghcr.io
46+ username : ${{ github.actor }}
47+ password : ${{ secrets.GITHUB_TOKEN }}
48+
49+ - name : Cache
50+ uses : actions/cache@v3
51+ id : cache
52+ with :
53+ path : |
54+ target
55+ registry
56+ git
57+ key : cache-${{ hashFiles('Dockerfile') }}
58+
59+ # Might be helpful later, but isn't working right now
60+ # - name: Inject Container Build Cache
61+ # uses: reproducible-containers/[email protected] 62+ # with:
63+ # cache-map: |
64+ # {
65+ # "registry": "/usr/local/cargo/registry/cache",
66+ # "idnex": "/usr/local/cargo/registry/index",
67+ # "git": "/usr/local/cargo/git/db",
68+ # "target": "/usr/src/embed-server/target"
69+ # }
70+ # skip-extraction: ${{ steps.cache.outputs.cache-hit }}
71+
72+ - name : Build and push
73+ uses : docker/build-push-action@v6
74+ with :
75+ push : true
76+ file : Dockerfile
77+ tags : ${{ steps.meta.outputs.tags }}
78+ labels : ${{ steps.meta.outputs.labels }}
79+ cache-from : type=gha
80+ cache-to : type=gha,mode=max
0 commit comments