-
Notifications
You must be signed in to change notification settings - Fork 5
122 lines (108 loc) · 4.73 KB
/
build-sealos-cluster-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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=sealaf
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 sealaf"
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"}'