1
+ name : Publish Docker Image
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ tags :
8
+ - ' v*' # Push events to tags matching v*, i.e. v1.0, v20.15.10
9
+
10
+ jobs :
11
+ build-and-push :
12
+ name : Build and Push Docker Image
13
+ runs-on : ubuntu-latest
14
+ permissions :
15
+ contents : read
16
+ packages : write # Needed for GHCR
17
+
18
+ steps :
19
+ - name : Checkout code
20
+ uses : actions/checkout@v3
21
+
22
+ - name : Set up QEMU
23
+ uses : docker/setup-qemu-action@v2
24
+ with :
25
+ platforms : ' arm64,amd64'
26
+
27
+ - name : Set up Docker Buildx
28
+ uses : docker/setup-buildx-action@v2
29
+ id : buildx
30
+ with :
31
+ install : true
32
+
33
+ - name : Extract metadata (tags, labels)
34
+ id : meta
35
+ uses : docker/metadata-action@v4
36
+ with :
37
+ images : |
38
+ gitmotion/ollama-api-server
39
+ ghcr.io/${{ github.repository }}
40
+ tags : |
41
+ type=semver,pattern={{version}}
42
+ type=semver,pattern={{major}}.{{minor}}
43
+ type=raw,value=latest,enable={{is_default_branch}}
44
+
45
+ - name : Set Package Version
46
+ id : package_version
47
+ run : |
48
+ VERSION=$(node -p "require('./package.json').version")
49
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
50
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
51
+
52
+ - name : Login to Docker Hub
53
+ uses : docker/login-action@v2
54
+ with :
55
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
56
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
57
+
58
+ - name : Login to GitHub Container Registry
59
+ uses : docker/login-action@v2
60
+ with :
61
+ registry : ghcr.io
62
+ username : ${{ github.repository_owner }}
63
+ password : ${{ secrets.GH_TOKEN }}
64
+
65
+ - name : Build and push Docker image
66
+ uses : docker/build-push-action@v4
67
+ with :
68
+ context : .
69
+ push : true
70
+ platforms : linux/amd64,linux/arm64
71
+ tags : |
72
+ gitmotion/ollama-api-server:latest
73
+ gitmotion/ollama-api-server:${{ env.VERSION }}
74
+ ghcr.io/${{ github.repository }}:latest
75
+ ghcr.io/${{ github.repository }}:${{ env.VERSION }}
76
+ labels : ${{ steps.meta.outputs.labels }}
77
+ cache-from : type=gha
78
+ cache-to : type=gha,mode=max
79
+ build-args : |
80
+ VERSION=${{ env.VERSION }}
81
+
82
+ - name : Update Docker Hub Description
83
+ uses : peter-evans/dockerhub-description@v3
84
+ with :
85
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
86
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
87
+ repository : gitmotion/ollama-api-server
88
+ short-description : " Expose a local 🦙 ollama api behind defined api keys - easy setup with docker!"
89
+ readme-filepath : ./README.md
0 commit comments