-
Notifications
You must be signed in to change notification settings - Fork 2.1k
151 lines (137 loc) · 5.31 KB
/
cloud.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build Cloud Cluster image
on:
workflow_call:
inputs:
push_image:
description: 'Push image'
required: false
type: boolean
default: false
push_image_tag:
description: 'Push all-in-one image tag, default is latest'
default: 'latest'
required: false
type: string
build_from:
description: 'Build all-in-one image from components image tag, default is latest'
default: 'latest'
required: false
type: string
workflow_dispatch:
inputs:
push_image:
description: 'Push image'
required: false
type: boolean
default: false
push_image_tag:
description: 'Push all-in-one image tag, default is latest'
default: 'latest'
required: false
type: string
build_from:
description: 'Build all-in-one image from components image tag, default is latest'
default: 'latest'
required: false
type: string
push:
branches: [ "main" ]
paths:
- "deploy/cloud/**"
- ".github/workflows/cloud.yml"
- "!**/*.md"
- "!**/*.yaml"
pull_request:
branches: [ "*" ]
paths:
- "deploy/cloud/**"
- ".github/workflows/cloud.yml"
- "!**/*.md"
- "!**/*.yaml"
env:
# Common versions
GO_VERSION: "1.20"
DEFAULT_OWNER: "labring"
jobs:
save-sealos:
uses: ./.github/workflows/import-save-sealos.yml
build-cluster-image:
if: ${{ (github.event_name == 'release') ||(github.event_name == 'push') || (inputs.push_image == true) }}
needs:
- save-sealos
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Expose git commit data
uses: rlespinasse/git-commit-data-action@v1
- name: Check if tag
id: check_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "isTag=true" >> "$GITHUB_OUTPUT"
else
echo "isTag=false" >> "$GITHUB_OUTPUT"
fi
- name: Prepare
id: prepare
run: |
bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}"
echo repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud >> $GITHUB_OUTPUT
- name: Download sealos
uses: actions/download-artifact@v3
with:
name: sealos
path: /tmp/
- name: Verify sealos
run: |
sudo chmod a+x /tmp/sealos
sudo mv /tmp/sealos /usr/bin/sealos
sudo sealos version
# todo: mutate image tag in images/shim and scripts or change scripts to use changeable tags
- name: Sealos login to ghcr.io
# if push to master, then login to ghcr.io
run: |
sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io
- name: Build sealos cloud cluster image
working-directory: deploy/cloud
run: |
[ -z "${{ inputs.build_from }}" ] && BuildFromTag="latest" || BuildFromTag="${{ inputs.build_from }}"; echo "BuildFromTag=${BuildFromTag}"
sed -i "s#labring#${{ github.repository_owner }}#g" init.sh
sed -i "s#labring#${{ github.repository_owner }}#g" etc/sealos/desktop-config.yaml
sed -i "s#latest#${BuildFromTag}#g" init.sh
sed -i "s#latest#${BuildFromTag}#g" etc/sealos/desktop-config.yaml
sudo bash init.sh amd64
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}-amd64 --platform linux/amd64 -f Kubefile
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:latest-amd64 --platform linux/amd64 -f Kubefile
# delete old registry cache
sudo rm -rf registry
sudo rm -rf tars
sudo bash init.sh arm64
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}-arm64 --platform linux/arm64 -f Kubefile
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:latest-arm64 --platform linux/arm64 -f Kubefile
- name: Manifest Cluster Images
# if push to master, then patch images to ghcr.io
run: |
sudo sealos images
bash docker/patch/manifest-cluster-images.sh ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}
bash docker/patch/manifest-cluster-images.sh ${{ steps.prepare.outputs.repo }}:latest
env:
OWNER: ${{ github.repository_owner }}
# todo: build multi-arch images
- name: Renew issue and Sync Images
uses: labring/[email protected]
if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
with:
version: v0.0.8-rc1
env:
GH_TOKEN: "${{ secrets.GH_PAT }}"
SEALOS_TYPE: "issue_renew"
SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos"
SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.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 }}/sealos-cloud:${{ steps.prepare.outputs.tag_name }}"