-
Notifications
You must be signed in to change notification settings - Fork 74
65 lines (54 loc) · 2.24 KB
/
docker-image.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
# docker-image.yml
name: Publish Docker image # workflow名称,可以在Github项目主页的【Actions】中看到所有的workflow
on: # 配置触发workflow的事件
push:
branches: # 添加这一行来指定触发分支
- 'main' # 两个星号代表任意分支
tags: # tag更新时触发此workflow
- '*'
jobs: # workflow中的job
push_to_registry: # job的名字
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest # job运行的基础环境
strategy:
matrix:
include:
- platform: linux/amd64
tag_suffix: amd64
- platform: linux/arm/v7
tag_suffix: armv7
- platform: linux/arm64
tag_suffix: arm64
steps: # 一个job由一个或多个step组成
- name: Check out the repo
uses: actions/checkout@v2 # 官方的action,获取代码
- name: Install jq
run: sudo apt-get install jq
- name: Extract package version
id: package_version
run: echo "::set-output name=VERSION::$(jq -r '.version' package.json)"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1 # 三方的action操作, 执行docker login
with:
username: ${{ secrets.DOCKERHUB_USERNAME }} # 配置dockerhub的认证,在Github项目主页 【Settings】 -> 【Secrets】 添加对应变量
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3 # 抽取项目信息,主要是镜像的tag
with:
images: atorber/chatflow-worker
- name: Build and push Docker image
uses: docker/build-push-action@v2 # docker build & push
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platform }}
tags: |
atorber/chatflow:${{ matrix.tag_suffix }}-${{ steps.package_version.outputs.VERSION }}
atorber/chatflow:${{ matrix.tag_suffix }}-latest
push: true
labels: ${{ steps.meta.outputs.labels }}