mirror of
https://github.com/alibaba/higress.git
synced 2026-02-25 05:01:19 +08:00
259 lines
7.9 KiB
YAML
259 lines
7.9 KiB
YAML
name: Build Docker Images and Push to Image Registry
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
workflow_dispatch: ~
|
|
|
|
jobs:
|
|
build-controller-image:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: image-registry-controller
|
|
env:
|
|
CONTROLLER_IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }}
|
|
CONTROLLER_IMAGE_NAME: ${{ vars.CONTROLLER_IMAGE_NAME || 'higress/higress' }}
|
|
steps:
|
|
- name: "Checkout ${{ github.ref }}"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
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: "Setup Go"
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 1.22
|
|
|
|
- name: Setup Golang Caches
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |-
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ github.run_id }}
|
|
restore-keys: ${{ runner.os }}-go
|
|
|
|
- name: Calculate Docker metadata
|
|
id: docker-meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.CONTROLLER_IMAGE_REGISTRY }}/${{ env.CONTROLLER_IMAGE_NAME }}
|
|
tags: |
|
|
type=sha
|
|
type=ref,event=tag
|
|
type=semver,pattern={{version}}
|
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.CONTROLLER_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
|
|
GOPROXY="https://proxy.golang.org,direct" IMG_URL="$image" make docker-buildx-push
|
|
BUILT_IMAGE="$image"
|
|
else
|
|
docker buildx imagetools create $BUILT_IMAGE --tag $image
|
|
fi
|
|
done
|
|
|
|
build-pilot-image:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: image-registry-pilot
|
|
env:
|
|
PILOT_IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }}
|
|
PILOT_IMAGE_NAME: ${{ vars.PILOT_IMAGE_NAME || 'higress/pilot' }}
|
|
steps:
|
|
- name: "Checkout ${{ github.ref }}"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
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: "Setup Go"
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 1.22
|
|
|
|
- name: Setup Golang Caches
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |-
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ github.run_id }}
|
|
restore-keys: ${{ runner.os }}-go
|
|
|
|
- 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-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Calculate Docker metadata
|
|
id: docker-meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.PILOT_IMAGE_REGISTRY }}/${{ env.PILOT_IMAGE_NAME }}
|
|
tags: |
|
|
type=sha
|
|
type=ref,event=tag
|
|
type=semver,pattern={{version}}
|
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.PILOT_IMAGE_REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build Pilot-Discovery 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
|
|
TAG=${image#*:}
|
|
HUB=${image%:*}
|
|
HUB=${HUB%/*}
|
|
BUILT_IMAGE="$HUB/pilot:$TAG"
|
|
GOPROXY="https://proxy.golang.org,direct" IMG_URL="$BUILT_IMAGE" make build-istio
|
|
fi
|
|
if [ "$BUILT_IMAGE" != "$image" ]; then
|
|
docker buildx imagetools create $BUILT_IMAGE --tag $image
|
|
fi
|
|
done
|
|
|
|
build-gateway-image:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: image-registry-gateway
|
|
env:
|
|
GATEWAY_IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }}
|
|
GATEWAY_IMAGE_NAME: ${{ vars.GATEWAY_IMAGE_NAME || 'higress/gateway' }}
|
|
steps:
|
|
- name: "Checkout ${{ github.ref }}"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
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: "Setup Go"
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 1.22
|
|
|
|
- name: Setup Golang Caches
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |-
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ github.run_id }}
|
|
restore-keys: ${{ runner.os }}-go
|
|
|
|
- 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-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Calculate Docker metadata
|
|
id: docker-meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.GATEWAY_IMAGE_REGISTRY }}/${{ env.GATEWAY_IMAGE_NAME }}
|
|
tags: |
|
|
type=sha
|
|
type=ref,event=tag
|
|
type=semver,pattern={{version}}
|
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.GATEWAY_IMAGE_REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build Gateway 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
|
|
TAG=${image#*:}
|
|
HUB=${image%:*}
|
|
HUB=${HUB%/*}
|
|
BUILT_IMAGE="$HUB/proxyv2:$TAG"
|
|
GOPROXY="https://proxy.golang.org,direct" IMG_URL="$BUILT_IMAGE" make build-gateway
|
|
fi
|
|
if [ "$BUILT_IMAGE" != "$image" ]; then
|
|
docker buildx imagetools create $BUILT_IMAGE --tag $image
|
|
fi
|
|
done
|