-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (106 loc) · 4.05 KB
/
build-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Build and Push Daemon
on:
push:
branches:
- "main"
- "deploy/dev"
release:
types: [published]
concurrency:
group: build-push-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DIFY_DAEMON_IMAGE_NAME: ${{ vars.DIFY_DAEMON_IMAGE_NAME || 'langgenius/dify-plugin-daemon' }}
jobs:
build:
runs-on: ${{ matrix.platform == 'linux/arm64' && 'arm64_runner' || 'ubuntu-latest' }}
if: github.repository == 'langgenius/dify-plugin-daemon'
strategy:
matrix:
include:
- service_name: "build-serverless-daemon-amd64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/amd64
scope: serverless
- service_name: "build-serverless-daemon-arm64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/arm64
scope: serverless
- service_name: "build-local-daemon-amd64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/amd64
scope: local
- service_name: "build-local-daemon-arm64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/arm64
scope: local
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DIFY_DAEMON_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Run Build Docker Image
run: docker build -t dify-plugin-daemon -f ./docker/${{ matrix.scope }}/Dockerfile .
- name: Tag Docker Images
run:
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n');
do
docker tag dify-plugin-daemon "$tag-${{ matrix.scope }}-${{ env.PLATFORM_PAIR }}";
done
- name: Push Docker Image
run:
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n');
do
docker push $tag-${{ matrix.scope }}-${{ env.PLATFORM_PAIR }};
done
create-manifest:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
scope: [serverless, local]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DIFY_DAEMON_IMAGE_NAME || 'langgenius/dify-plugin-daemon' }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build Universal Docker Images
run:
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n');
do
docker manifest create $tag-${{ matrix.scope }} $tag-${{ matrix.scope }}-linux-amd64 $tag-${{ matrix.scope }}-linux-arm64;
docker manifest push $tag-${{ matrix.scope }};
done