mirror of
https://github.com/alibaba/higress.git
synced 2026-04-21 12:07:26 +08:00
107 lines
3.4 KiB
YAML
107 lines
3.4 KiB
YAML
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
|