Skip to content

docker_build_success #545

docker_build_success

docker_build_success #545

name: build-sealos-cluster-image
on:
repository_dispatch:
types: [docker_build_success, build-scripts-updated]
workflow_dispatch:
env:
# Common versions
GO_VERSION: "1.19"
concurrency:
group: build-sealos-cluster-image-${{ github.ref }}
cancel-in-progress: true
jobs:
build_cluster_image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.ref }}
- name: Prepare
id: prepare
run: |
IMAGE=laf
TAG=${{ github.event.client_payload.version }}
echo "tag=${TAG}" >> $GITHUB_ENV
echo "image=${IMAGE}" >> $GITHUB_ENV
- name: Remove builtin docker
run: |
sudo apt-get remove -y moby-engine moby-cli moby-buildx moby-compose
- name: Install sealos
run: |
echo "deb [trusted=yes] https://apt.fury.io/labring/ /" | sudo tee /etc/apt/sources.list.d/labring.list
sudo apt update
sudo apt install sealos=4.1.4
sudo sealos version
- name: Install buildah
run: |
sudo apt remove buildah -y || true
arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
sudo echo "download buildah in https://github.com/labring/cluster-image/releases/download/depend/buildah.linux.${arch}"
sudo wget -qO "buildah" "https://github.com/labring/cluster-image/releases/download/depend/buildah.linux.${arch}"
sudo chmod a+x buildah
sudo mv buildah /usr/bin
- name: Login GHCR.io
run: |
echo "run: buildah login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io"
sudo buildah login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Build cluster image
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/${{ env.image }}
VERSION: ${{ env.tag }}
working-directory: build
run: |
echo $IMAGE:$VERSION
sudo sealos build -t $IMAGE:$VERSION-arm64 --platform linux/arm64 -f Kubefile .
sudo rm -rf registry
sudo sealos build -t $IMAGE:$VERSION-amd64 --platform linux/amd64 -f Kubefile .
sudo sealos images
- name: Push cluster image to ghcr.io
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/${{ env.image }}
VERSION: ${{ env.tag }}
run: |
sudo buildah images
sudo buildah push $IMAGE:$VERSION-amd64
sudo buildah push $IMAGE:$VERSION-arm64
sudo buildah manifest create $IMAGE:$VERSION
sudo buildah manifest add $IMAGE:$VERSION docker://$IMAGE:$VERSION-amd64
sudo buildah manifest add $IMAGE:$VERSION docker://$IMAGE:$VERSION-arm64
sudo buildah manifest push --all $IMAGE:$VERSION docker://$IMAGE:$VERSION
- name: Push cluster image to docker.io
env:
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ env.image }}
IMAGE: docker.io/${{ secrets.DOCKER_USERNAME }}/${{ env.image }}
VERSION: ${{ env.tag }}
run: |
sudo buildah login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker.io
sudo buildah tag $GHCR_IMAGE:$VERSION-amd64 $IMAGE:$VERSION-amd64
sudo buildah tag $GHCR_IMAGE:$VERSION-arm64 $IMAGE:$VERSION-arm64
sudo buildah push $IMAGE:$VERSION-amd64
sudo buildah push $IMAGE:$VERSION-arm64
sudo buildah manifest create $IMAGE:$VERSION
sudo buildah manifest add $IMAGE:$VERSION docker://$IMAGE:$VERSION-amd64
sudo buildah manifest add $IMAGE:$VERSION docker://$IMAGE:$VERSION-arm64
sudo buildah manifest push --all $IMAGE:$VERSION docker://$IMAGE:$VERSION
- name: Renew issue and Sync Images
uses: labring/[email protected]
with:
version: v0.0.8-rc1
env:
GH_TOKEN: "${{ secrets.GH_PAT }}"
SEALOS_TYPE: "issue_renew"
SEALOS_ISSUE_TITLE: "【DaylyReport】 Auto build for laf"
SEALOS_ISSUE_BODYFILE: "build/README.md"
SEALOS_ISSUE_LABEL: "dayly-report"
SEALOS_ISSUE_TYPE: "day"
SEALOS_ISSUE_REPO: "labring-actions/cluster-image"
SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/${{ env.image }}:${{ env.tag }}"
trigger-workflow-e2e:
needs: [build_cluster_image]
runs-on: ubuntu-latest
steps:
- name: trigger cluster image workflow
uses: peter-evans/repository-dispatch@v2
with:
event-type: cluster_image_build_success
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "version": "latest"}'