From 91c3d200dfe8dd57c1d9ecfe7eea6982bd236756 Mon Sep 17 00:00:00 2001 From: xiaomage Date: Thu, 30 Apr 2026 10:20:28 +0800 Subject: [PATCH] feat(action): add docker build and push action. --- .github/workflows/docker.yml | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..9105eb1 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,97 @@ +# Copyright 2025 RustFS Team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Publish Docker Image + +on: + workflow_run: + workflows: ["CI", "Publish Crate", "Security Audit"] + types: [ completed ] + workflow_dispatch: + inputs: + version: + description: "Release version to publish, e.g. 1.0.0" + required: true + default: "1.0.0" + type: string + +permissions: + contents: read + packages: write + +jobs: + push-mcp-images: + runs-on: ubicloud-standard-2 + if: | + github.event_name == 'workflow_dispatch' || + (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Normalize version + id: version + run: | + set -eux + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + RAW="${{ github.event.inputs.version }}" + else + RAW="${{ github.event.workflow_run.head_branch }}" + fi + RAW_TAG="${RAW#refs/tags/}" + VERSION="${RAW_TAG#v}" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Login to Quay.io + # uses: docker/login-action@v3 + # with: + # registry: quay.io + # username: ${{ secrets.QUAY_USERNAME }} + # password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + rustfs/mcp:latest + rustfs/mcp:${{ steps.version.outputs.version }} + ghcr.io/${{ github.repository_owner }}/mcp:latest + ghcr.io/${{ github.repository_owner }}/mcp:${{ steps.version.outputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + VERSION=${{ steps.version.outputs.version }}