Upload Image #599
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: Upload Image | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: "0 18 * * *" | |
release: | |
types: [published] | |
jobs: | |
build-specific-architecture: | |
strategy: | |
matrix: | |
arch: [amd64, arm64] | |
image: [chaos-daemon, chaos-mesh, chaos-dashboard, chaos-kernel, chaos-dlv] | |
outputs: | |
image_tag: ${{ steps.image_tag.outputs.image_tag }} | |
runs-on: ${{ fromJson('{"amd64":"ubuntu-latest", "arm64":["self-hosted", "Linux", "ARM64"]}')[matrix.arch] }} | |
steps: | |
- uses: actions/checkout@master | |
with: | |
# it requires all the tags and branch for generation the correct GitVersion with hack/version.sh | |
fetch-depth: 0 | |
- name: Extract Image Tag | |
shell: bash | |
run: | | |
IMAGE_TAG=${GITHUB_REF##*/} | |
if [ "${IMAGE_TAG}" = "master" ] ; then | |
IMAGE_TAG=latest; | |
fi | |
echo "::set-output name=image_tag::$(echo $IMAGE_TAG)" | |
id: image_tag | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Chaos Mesh | |
env: | |
IMAGE_TAG: ${{ steps.image_tag.outputs.image_tag }} | |
ARCH: ${{ matrix.arch }} | |
IMAGE: ${{ matrix.image }} | |
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} | |
run: | | |
if [ "${IMAGE}" = "chaos-dashboard" ]; then | |
UI=1 | |
else | |
UI=0 | |
fi | |
# ${VAR,,} convert VAR to lower case | |
make -B \ | |
TARGET_PLATFORM=$ARCH \ | |
IMAGE_TAG=$IMAGE_TAG-$ARCH \ | |
IMAGE_DEV_ENV_BUILD=1 \ | |
IMAGE_BUILD_ENV_BUILD=1 \ | |
IMAGE_PROJECT=${GITHUB_REPOSITORY_OWNER,,} \ | |
IMAGE_BUILD_ENV_PROJECT=${GITHUB_REPOSITORY_OWNER,,} \ | |
IMAGE_DEV_ENV_PROJECT=${GITHUB_REPOSITORY_OWNER,,} \ | |
IMAGE_REGISTRY=ghcr.io \ | |
UI=$UI \ | |
image-$IMAGE | |
- name: Upload Chaos Mesh | |
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:$IMAGE_TAG-$ARCH | |
upload-manifest: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: [chaos-daemon, chaos-mesh, chaos-dashboard, chaos-kernel, chaos-dlv] | |
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:$IMAGE_TAG \ | |
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG-amd64 \ | |
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG-arm64 | |
docker manifest annotate ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG \ | |
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG-amd64 \ | |
--os linux --arch amd64 | |
docker manifest annotate ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG \ | |
ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG-arm64 \ | |
--os linux --arch arm64 | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Chaos Mesh | |
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:$IMAGE_TAG |