@@ -14,7 +14,7 @@ concurrency:
1414 cancel-in-progress : true
1515
1616jobs :
17- build_bisheng :
17+ build_bisheng_arm :
1818 runs-on : ubuntu-latest
1919 # if: startsWith(github.event.ref, 'refs/tags')
2020 steps :
3838 # DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
3939 username : ${{ secrets.DOCKERHUB_USERNAME }}
4040 password : ${{ secrets.DOCKERHUB_TOKEN }}
41-
42- # - name: Login to DockerHub
43- # uses: docker/login-action@v1
44- # with:
45- # registry: https://cr.dataelem.com/
46- # username: ${{ secrets.CR_DOCKERHUB_USERNAME }}
47- # password: ${{ secrets.CR_DOCKERHUB_TOKEN }}
4841
4942 # 构建 backend 并推送到 Docker hub
5043 - name : Set up QEMU
5346 - name : set up Docker Buildx
5447 uses : docker/setup-buildx-action@v3
5548
56- - name : install poetry
57- uses : snok/install-poetry@v1
58- with :
59- installer-parallel : true
60-
61- - name : Build backend amd64 and push
62- id : docker_build_backend_amd
63- uses : docker/build-push-action@v2
64- with :
65- # backend 的context目录
66- context : " ./src/backend/"
67- file : ./src/backend/base.Dockerfile
68- # 是否 docker push
69- push : true
70- # docker build arg, 注入 APP_NAME/APP_VERSION
71- platforms : linux/amd64
72- build-args : |
73- APP_NAME="bisheng-backend"
74- APP_VERSION=${{ steps.get_version.outputs.VERSION }}
75- PANDOC_ARCH=amd64
76- # 生成两个 docker tag: ${APP_VERSION} 和 latest
77- tags : |
78- ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}
7949 - name : Build backend arm64 and push
8050 id : docker_build_backend_arm
8151 uses : docker/build-push-action@v2
9363 PANDOC_ARCH=arm64
9464 # 生成两个 docker tag: ${APP_VERSION} 和 latest
9565 tags : |
96- ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}
66+ ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}-arm64
9767 # 获取提交信息
9868 - name : Process git message
9969 id : process_message
@@ -108,4 +78,75 @@ jobs:
10878 with :
10979 url : ${{ secrets.FEISHU_WEBHOOK }}
11080 method : ' POST'
111- data : ' {"msg_type":"post","content":{"post":{"zh_cn":{"title": "${{ steps.get_version.outputs.VERSION }}发布成功", "content": [[{"tag":"text","text":"基础镜像"},{"tag":"text","text":"${{ env.message }}"}]]}}}}'
81+ data : ' {"msg_type":"post","content":{"post":{"zh_cn":{"title": "${{ steps.get_version.outputs.VERSION }}发布成功", "content": [[{"tag":"text","text":"基础镜像"},{"tag":"text","text":"${{ env.message }}"}]]}}}}'
82+
83+ build_bisheng_amd :
84+ runs-on : ubuntu-latest
85+ steps :
86+ - name : checkout
87+ uses : actions/checkout@v2
88+
89+ - name : Get version
90+ id : get_version
91+ run : |
92+ echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
93+
94+ - name : Set Environment Variable
95+ run : echo "RELEASE_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
96+
97+ # 登录 docker hub
98+ - name : Login to DockerHub
99+ uses : docker/login-action@v1
100+ with :
101+ # GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
102+ # DOCKERHUB_USERNAME 是 docker hub 账号名.
103+ # DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
104+ username : ${{ secrets.DOCKERHUB_USERNAME }}
105+ password : ${{ secrets.DOCKERHUB_TOKEN }}
106+
107+ - name : Build backend amd64 and push
108+ id : docker_build_backend_amd
109+ uses : docker/build-push-action@v2
110+ with :
111+ # backend 的context目录
112+ context : " ./src/backend/"
113+ file : ./src/backend/base.Dockerfile
114+ # 是否 docker push
115+ push : true
116+ # docker build arg, 注入 APP_NAME/APP_VERSION
117+ platforms : linux/amd64
118+ build-args : |
119+ APP_NAME="bisheng-backend"
120+ APP_VERSION=${{ steps.get_version.outputs.VERSION }}
121+ PANDOC_ARCH=amd64
122+ # 生成两个 docker tag: ${APP_VERSION} 和 latest
123+ tags : |
124+ ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}-amd64
125+
126+ combine_two_images :
127+ runs-on : ubuntu-latest
128+ needs :
129+ - build_bisheng_amd
130+ - build_bisheng_arm
131+ steps :
132+ - name : Get version
133+ id : get_version
134+ run : |
135+ echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
136+
137+ - name : Set Environment Variable
138+ run : echo "RELEASE_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
139+
140+ # 登录 docker hub
141+ - name : Login to DockerHub
142+ uses : docker/login-action@v1
143+ with :
144+ # GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
145+ # DOCKERHUB_USERNAME 是 docker hub 账号名.
146+ # DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
147+ username : ${{ secrets.DOCKERHUB_USERNAME }}
148+ password : ${{ secrets.DOCKERHUB_TOKEN }}
149+ - name : Combine Two images
150+ run : |
151+ docker manifest create ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }} --amend ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}-arm64 --amend ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}-amd64
152+ docker manifest push ${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}
0 commit comments