1+ name : Docker Build and Publish Mock User Service
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+ paths :
8+ - ' cmd/**'
9+ - ' internal/**'
10+ - ' pkg/**'
11+ - ' deploy/docker/**'
12+ - ' go.mod'
13+ - ' go.sum'
14+ workflow_dispatch :
15+ inputs :
16+ version :
17+ description : ' Version tag for the image'
18+ required : true
19+ default : ' dev'
20+
21+ env :
22+ DOCKER_HUB_USERNAME : ifuryst
23+ ALIYUN_REGISTRY : registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem
24+ BUILDX_NO_DEFAULT_ATTESTATIONS : 1
25+ PUSH_LATEST : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
26+ SHOULD_LOGIN : ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
27+
28+ jobs :
29+ build-and-push :
30+ runs-on : ubuntu-latest
31+ permissions :
32+ contents : read
33+ packages : write
34+
35+ steps :
36+ - name : Checkout
37+ uses : actions/checkout@v4
38+
39+ - name : Set up Docker Buildx
40+ uses : docker/setup-buildx-action@v3
41+ with :
42+ platforms : linux/amd64,linux/arm64
43+
44+ - name : Login to Docker Hub
45+ if : env.SHOULD_LOGIN == 'true'
46+ uses : docker/login-action@v3
47+ with :
48+ username : ${{ env.DOCKER_HUB_USERNAME }}
49+ password : ${{ secrets.DOCKER_HUB_TOKEN }}
50+
51+ - name : Login to GitHub Container Registry
52+ if : env.SHOULD_LOGIN == 'true'
53+ uses : docker/login-action@v3
54+ with :
55+ registry : ghcr.io
56+ username : ${{ github.actor }}
57+ password : ${{ secrets.GITHUB_TOKEN }}
58+
59+ - name : Login to Aliyun Container Registry
60+ if : env.SHOULD_LOGIN == 'true'
61+ uses : docker/login-action@v3
62+ with :
63+ registry : ${{ env.ALIYUN_REGISTRY }}
64+ username : ${{ secrets.ALIYUN_USERNAME }}
65+ password : ${{ secrets.ALIYUN_PASSWORD }}
66+
67+ - name : Build and push mock-user-svc image
68+ uses : docker/build-push-action@v5
69+ with :
70+ context : .
71+ file : deploy/docker/multi/mock-user-svc/Dockerfile
72+ push : true
73+ platforms : linux/amd64,linux/arm64
74+ cache-from : type=gha
75+ cache-to : type=gha,mode=max
76+ tags : |
77+ ${{ env.PUSH_LATEST == 'true' && format('{0}/mcp-gateway-mock-user-svc:latest', env.DOCKER_HUB_USERNAME) || '' }}
78+ ${{ format('{0}/mcp-gateway-mock-user-svc:{1}', env.DOCKER_HUB_USERNAME, github.ref_name) }}
79+ ${{ env.PUSH_LATEST == 'true' && format('ghcr.io/{0}/mock-user-svc:latest', github.repository) || '' }}
80+ ${{ format('ghcr.io/{0}/mock-user-svc:{1}', github.repository, github.ref_name) }}
81+ ${{ env.PUSH_LATEST == 'true' && format('{0}/mcp-gateway-mock-user-svc:latest', env.ALIYUN_REGISTRY) || '' }}
82+ ${{ format('{0}/mcp-gateway-mock-user-svc:{1}', env.ALIYUN_REGISTRY, github.ref_name) }}
0 commit comments