Build All-in-One Image and Push to Image Registry #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build All-in-One Image and Push to Image Registry | |
on: | |
push: | |
tags: | |
- "aio-v*.*.*" | |
workflow_dispatch: ~ | |
jobs: | |
build-aio-image: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }} | |
IMAGE_NAME: ${{ vars.ALL_IN_ONE_IMAGE_NAME || 'higress/all-in-one' }} | |
steps: | |
- name: "Checkout ${{ github.ref }}" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Calculate Docker metadata | |
id: docker-meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=sha | |
type=match,pattern=aio-v(.*),group=1 | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
- name: Login to Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build Docker Image and Push | |
run: | | |
cd all-in-one/ | |
readarray -t IMAGES <<< "${{ steps.docker-meta.outputs.tags }}" | |
baseImage="" | |
for image in ${IMAGES[@]}; do | |
echo "Image: $image" | |
if [ -z "$baseImage" ]; then | |
IMG="${image}" make docker-buildx-push | |
baseImage="$image" | |
else | |
docker buildx imagetools create "$baseImage" --tag "$image" | |
fi | |
done |