Skip to content

refactor: optimize allInjected and allRecovered states (#4199) #1

refactor: optimize allInjected and allRecovered states (#4199)

refactor: optimize allInjected and allRecovered states (#4199) #1

name: Upload Env Images
on:
workflow_dispatch: {}
push:
paths:
- "images/build-env/Dockerfile"
- "images/dev-env/Dockerfile"
branches:
- master
- release-*
permissions: read-all
jobs:
build-specific-architecture:
permissions:
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#authenticating-to-package-registries-on-github
packages: write
runs-on: ubuntu-20.04
strategy:
matrix:
arch: [amd64, arm64]
image: [dev, build]
outputs:
image_tag: ${{ steps.image_tag.outputs.image_tag }}
steps:
- uses: actions/checkout@v4
- name: Extract Image Tag
shell: bash
run: |
# we assume that both image tags of build-env and dev-env are same during this workflow
IMAGE_TAG=$(./hack/env-image-tag.sh build-env)
echo "::set-output name=image_tag::$(echo $IMAGE_TAG)"
id: image_tag
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Chaos Mesh Env
env:
IMAGE_TAG: ${{ steps.image_tag.outputs.image_tag }}
ARCH: ${{ matrix.arch }}
IMAGE: ${{ matrix.image }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
export IMAGE_${IMAGE^^}_ENV_BUILD=1
export IMAGE_${IMAGE^^}_ENV_TAG=$IMAGE_TAG-$ARCH
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# ${VAR,,} convert VAR to lower case
make -B \
TARGET_PLATFORM=$ARCH \
IMAGE_TAG=$IMAGE_TAG-$ARCH \
image-$IMAGE-env
- name: Upload Chaos Mesh Env
env:
IMAGE_TAG: ${{ steps.image_tag.outputs.image_tag }}
ARCH: ${{ matrix.arch }}
IMAGE: ${{ matrix.image }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
# ${VAR,,} convert VAR to lower case
docker push ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG-$ARCH
upload-manifest:
permissions:
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#authenticating-to-package-registries-on-github
packages: write
runs-on: ubuntu-20.04
strategy:
matrix:
image: [dev, build]
needs: build-specific-architecture
steps:
- name: Build Chaos Mesh manifest
env:
IMAGE: ${{ matrix.image }}
IMAGE_TAG: ${{ needs.build-specific-architecture.outputs.image_tag }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
# ${VAR,,} convert VAR to lower case
docker manifest create ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG \
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG-amd64 \
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG-arm64
docker manifest annotate ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG \
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG-amd64 \
--os linux --arch amd64
docker manifest annotate ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG \
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG-arm64 \
--os linux --arch arm64
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Chaos Mesh Env
env:
IMAGE: ${{ matrix.image }}
IMAGE_TAG: ${{ needs.build-specific-architecture.outputs.image_tag }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
# ${VAR,,} convert VAR to lower case
docker manifest push ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE-env:$IMAGE_TAG