Skip to content

Commit b76cead

Browse files
authored
feat(action): add docker build and push action. (#3)
1 parent 1e3fb0c commit b76cead

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/docker.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2025 RustFS Team
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Publish Docker Image
16+
17+
on:
18+
workflow_run:
19+
workflows: ["CI", "Publish Crate", "Security Audit"]
20+
types: [ completed ]
21+
workflow_dispatch:
22+
inputs:
23+
version:
24+
description: "Release version to publish, e.g. 1.0.0"
25+
required: true
26+
default: "1.0.0"
27+
type: string
28+
29+
permissions:
30+
contents: read
31+
packages: write
32+
33+
jobs:
34+
push-mcp-images:
35+
runs-on: ubicloud-standard-2
36+
if: |
37+
github.event_name == 'workflow_dispatch' ||
38+
(github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push')
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
44+
- name: Normalize version
45+
id: version
46+
run: |
47+
set -eux
48+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49+
RAW="${{ github.event.inputs.version }}"
50+
else
51+
RAW="${{ github.event.workflow_run.head_branch }}"
52+
fi
53+
RAW_TAG="${RAW#refs/tags/}"
54+
VERSION="${RAW_TAG#v}"
55+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
56+
57+
- name: Set up QEMU
58+
uses: docker/setup-qemu-action@v3
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Login to DockerHub
64+
uses: docker/login-action@v3
65+
with:
66+
username: ${{ secrets.DOCKERHUB_USERNAME }}
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}
68+
69+
- name: Login to GitHub Container Registry
70+
uses: docker/login-action@v3
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.repository_owner }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
76+
# - name: Login to Quay.io
77+
# uses: docker/login-action@v3
78+
# with:
79+
# registry: quay.io
80+
# username: ${{ secrets.QUAY_USERNAME }}
81+
# password: ${{ secrets.QUAY_PASSWORD }}
82+
83+
- name: Build and push
84+
uses: docker/build-push-action@v5
85+
with:
86+
context: .
87+
platforms: linux/amd64,linux/arm64
88+
push: true
89+
tags: |
90+
rustfs/mcp:latest
91+
rustfs/mcp:${{ steps.version.outputs.version }}
92+
ghcr.io/${{ github.repository_owner }}/mcp:latest
93+
ghcr.io/${{ github.repository_owner }}/mcp:${{ steps.version.outputs.version }}
94+
cache-from: type=gha
95+
cache-to: type=gha,mode=max
96+
build-args: |
97+
VERSION=${{ steps.version.outputs.version }}

0 commit comments

Comments
 (0)