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