From 23a0299d3b28f5a7b82ba58af728e27f92829c87 Mon Sep 17 00:00:00 2001 From: daofeng Date: Sun, 22 Mar 2026 22:11:03 +0800 Subject: [PATCH] feat: add CI workflow to build and push plugin-server image on release (#3632) --- .../build-and-push-plugin-server-image.yml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .github/workflows/build-and-push-plugin-server-image.yml diff --git a/.github/workflows/build-and-push-plugin-server-image.yml b/.github/workflows/build-and-push-plugin-server-image.yml new file mode 100644 index 000000000..158c479e3 --- /dev/null +++ b/.github/workflows/build-and-push-plugin-server-image.yml @@ -0,0 +1,106 @@ +name: Build Plugin Server Image and Push + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + inputs: + plugin_server_ref: + description: "plugin-server repo ref (branch/tag/commit, default: main)" + required: false + default: "main" + type: string + version: + description: "Version tag (optional, without leading v)" + required: false + type: string + +jobs: + build-plugin-server-image: + runs-on: ubuntu-latest + environment: + name: image-registry-plugin-server + env: + IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }} + IMAGE_NAME: ${{ vars.PLUGIN_SERVER_IMAGE_NAME || 'higress/plugin-server' }} + steps: + - name: "Clone plugin-server repository" + uses: actions/checkout@v4 + with: + repository: higress-group/plugin-server + ref: ${{ github.event.inputs.plugin_server_ref || 'main' }} + path: plugin-server + fetch-depth: 1 + + - name: Free Up GitHub Actions Ubuntu Runner Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:qemu-v7.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-plugin-server-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-plugin-server- + + - name: Determine version + id: version + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.version }}" ]]; then + echo "manual_version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + fi + + - name: Calculate Docker metadata + id: docker-meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha + type=ref,event=tag + type=semver,pattern={{version}} + type=raw,value=${{ steps.version.outputs.manual_version }},enable=${{ steps.version.outputs.manual_version != '' }} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + + - name: Login to Docker Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.IMAGE_REGISTRY }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build Docker Image and Push + run: | + BUILT_IMAGE="" + readarray -t IMAGES <<< "${{ steps.docker-meta.outputs.tags }}" + for image in "${IMAGES[@]}"; do + echo "Image: $image" + if [ "$BUILT_IMAGE" == "" ]; then + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + -t "$image" \ + -f plugin-server/Dockerfile \ + --push \ + plugin-server + BUILT_IMAGE="$image" + else + docker buildx imagetools create "$BUILT_IMAGE" --tag "$image" + fi + done