1
- name : Build and Push API Image
1
+ name : Build and Push API & Web
2
2
3
3
on :
4
4
push :
5
5
branches :
6
- - ' main'
7
- - ' deploy/dev'
6
+ - " main"
7
+ - " deploy/dev"
8
8
release :
9
- types : [ published ]
9
+ types : [published]
10
+
11
+ env :
12
+ DOCKERHUB_USER : ${{ secrets.DOCKERHUB_USER }}
13
+ DOCKERHUB_TOKEN : ${{ secrets.DOCKERHUB_TOKEN }}
14
+ DIFY_WEB_IMAGE_NAME : ${{ vars.DIFY_WEB_IMAGE_NAME || 'langgenius/dify-web' }}
15
+ DIFY_API_IMAGE_NAME : ${{ vars.DIFY_API_IMAGE_NAME || 'langgenius/dify-api' }}
10
16
11
17
jobs :
12
18
build-and-push :
13
19
runs-on : ubuntu-latest
14
20
if : github.event.pull_request.draft == false
21
+ strategy :
22
+ matrix :
23
+ include :
24
+ - service_name : " web"
25
+ image_name_env : " DIFY_WEB_IMAGE_NAME"
26
+ context : " web"
27
+ - service_name : " api"
28
+ image_name_env : " DIFY_API_IMAGE_NAME"
29
+ context : " api"
15
30
steps :
16
31
- name : Set up QEMU
17
32
uses : docker/setup-qemu-action@v3
@@ -22,14 +37,14 @@ jobs:
22
37
- name : Login to Docker Hub
23
38
uses : docker/login-action@v2
24
39
with :
25
- username : ${{ secrets .DOCKERHUB_USER }}
26
- password : ${{ secrets .DOCKERHUB_TOKEN }}
40
+ username : ${{ env .DOCKERHUB_USER }}
41
+ password : ${{ env .DOCKERHUB_TOKEN }}
27
42
28
43
- name : Extract metadata (tags, labels) for Docker
29
44
id : meta
30
45
uses : docker/metadata-action@v5
31
46
with :
32
- images : langgenius/dify-api
47
+ images : ${{ env[matrix.image_name_env] }}
33
48
tags : |
34
49
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
35
50
type=ref,event=branch
@@ -39,22 +54,11 @@ jobs:
39
54
- name : Build and push
40
55
uses : docker/build-push-action@v5
41
56
with :
42
- context : " {{defaultContext}}:api "
57
+ context : " {{defaultContext}}:${{ matrix.context }} "
43
58
platforms : ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
44
- build-args : |
45
- COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
59
+ build-args : COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
46
60
push : true
47
61
tags : ${{ steps.meta.outputs.tags }}
48
62
labels : ${{ steps.meta.outputs.labels }}
49
63
cache-from : type=gha
50
64
cache-to : type=gha,mode=max
51
-
52
- - name : Deploy to server
53
- if : github.ref == 'refs/heads/deploy/dev'
54
-
55
- with :
56
- host : ${{ secrets.SSH_HOST }}
57
- username : ${{ secrets.SSH_USER }}
58
- key : ${{ secrets.SSH_PRIVATE_KEY }}
59
- script : |
60
- ${{ secrets.SSH_SCRIPT }}
0 commit comments