11name : Docker Build and Push
22
33on :
4+ workflow_dispatch :
45 push :
56 branches : [main]
67 tags : ['v*']
@@ -13,7 +14,13 @@ permissions:
1314
1415jobs :
1516 build :
16- runs-on : ubuntu-latest
17+ strategy :
18+ matrix :
19+ archs :
20+ - arch : amd64
21+ - arch : arm64
22+ runs-on : ubuntu-24.04-arm
23+ runs-on : ${{ matrix.archs.runs-on || 'ubuntu-24.04' }}
1724
1825 steps :
1926 - name : Checkout code
@@ -29,25 +36,34 @@ jobs:
2936 registry : ghcr.io
3037 username : ${{ github.repository_owner }}
3138 password : ${{ secrets.GITHUB_TOKEN }}
32-
33- - name : Extract metadata for Docker
34- id : meta
35- uses : docker/metadata-action@v5
39+ - name : Login to Docker Hub
40+ if : github.event_name != 'pull_request'
41+ uses : docker/login-action@v3
42+ with :
43+ username : ${{ secrets.DOCKERHUB_USERNAME }}
44+ password : ${{ secrets.DOCKERHUB_TOKEN }}
45+ - name : Login to Ali Hub
46+ uses : docker/login-action@v3
3647 with :
37- images : ghcr.io/${{ github.repository }}
38- tags : |
39- type=ref,event=branch
40- type=ref,event=pr
41- type=semver,pattern={{version}}
42- type=semver,pattern={{major}}.{{minor}}
43- type=sha,format=short
48+ registry : registry.cn-hangzhou.aliyuncs.com
49+ username : ${{ secrets.ALI_HUB_USERNAME }}
50+ password : ${{ secrets.ALI_HUB_PASSWORD }}
4451
45- - name : Build and push Docker image
46- uses : docker/build-push-action@v5
52+ - name : Build for ${{ matrix.archs.arch }}
53+ id : build
54+ uses : docker/build-push-action@v6
4755 with :
4856 context : .
49- push : ${{ github.event_name != 'pull_request' }}
50- tags : ${{ steps.meta.outputs.tags }}
51- labels : ${{ steps.meta.outputs.labels }}
52- cache-from : type=gha
53- cache-to : type=gha,mode=max
57+ platforms : linux/${{ matrix.archs.arch }}
58+ labels : |
59+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
60+ org.opencontainers.image.description=https://github.com/${{ github.repository }} image
61+ outputs: |
62+ type=image,
63+ name=ghcr.io/${{ github.repository_owner }}/FastGPT-plugin:${{ github.sha }},
64+ ${{ secrets.ALI_IMAGE_NAME }}/FastGPT-plugin:${{ github.sha }},
65+ ${{ secrets.DOCKER_IMAGE_NAME }}/FastGPT-plugin:${{ github.sha }}
66+ push-by-digest=true,
67+ push=true
68+ cache-from : type=local,src=/tmp/.buildx-cache
69+ cache-to : type=local,dest=/tmp/.buildx-cache
0 commit comments