Skip to content

Commit c2ddc01

Browse files
authored
Merge pull request #2 from cuisongliu/fix-ci
Fix ci
2 parents 0e8b83f + d02a196 commit c2ddc01

3 files changed

Lines changed: 110 additions & 10 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: build-all-template-cluster-image-arm64
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- "scripts/build-cluster-image.sh"
8+
- ".github/workflows/build-all-template-cluster-image-arm64.yaml"
9+
jobs:
10+
gen-targets:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
targets: ${{ steps.get-targets.outputs.targets }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- name: Get all template files
20+
id: get-targets
21+
run: |
22+
files=$(find template/ -name "*.yaml" -type f | jq -R . | jq -s -c .)
23+
echo "targets=$files" >> "$GITHUB_OUTPUT"
24+
build:
25+
runs-on: ubuntu-24.04-arm
26+
permissions:
27+
contents: read
28+
packages: write
29+
needs: gen-targets
30+
strategy:
31+
matrix:
32+
target: ${{ fromJSON(needs.gen-targets.outputs.targets) }}
33+
fail-fast: false
34+
steps:
35+
- name: Free Disk Space (Ubuntu)
36+
uses: BRAINSia/free-disk-space@v2
37+
with:
38+
# this might remove tools that are actually needed,
39+
# if set to "true" but frees about 6 GB
40+
tool-cache: false
41+
42+
# all of these default to true, but feel free to set to
43+
# "false" if necessary for your workflow
44+
mandb: true
45+
android: true
46+
dotnet: true
47+
haskell: true
48+
large-packages: true
49+
docker-images: true
50+
swap-storage: true
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
with:
54+
fetch-depth: 0
55+
- name: Set up sealos
56+
run: |
57+
curl -sfL https://raw.githubusercontent.com/labring/sealos/main/scripts/install.sh | sh -s v5.1.0 labring/sealos
58+
- name: Build cluster image
59+
run: |
60+
if [[ $(basename ${{ matrix.target }}) == "index.yaml" ]]; then
61+
template_name=$(basename $(dirname ${{ matrix.target }}) | tr '[:upper:]' '[:lower:]')
62+
else
63+
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
64+
fi
65+
sudo bash scripts/build-cluster-image.sh ${{ matrix.target }} ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest-arm64
66+
#https://github.com/labring/sealos/issues/6112
67+
- name: Login to ghcr.io
68+
run: |
69+
sudo sealos logout docker.io || true
70+
sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
71+
- name: Push and save cluster image
72+
run: |
73+
if [[ $(basename ${{ matrix.target }}) == "index.yaml" ]]; then
74+
template_name=$(basename $(dirname ${{ matrix.target }}) | tr '[:upper:]' '[:lower:]')
75+
else
76+
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
77+
fi
78+
sudo sealos push ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest-arm64
79+
sudo sealos save ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest-arm64 -o $template_name.tar
80+
- name: Upload cluster image tar
81+
if: github.repository_owner == 'labring-sigs'
82+
run: |
83+
sudo -v ; curl https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash
84+
if [[ $(basename ${{ matrix.target }}) == "index.yaml" ]]; then
85+
template_name=$(basename $(dirname ${{ matrix.target }}) | tr '[:upper:]' '[:lower:]')
86+
else
87+
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
88+
fi
89+
ossutil64 cp -f -e ${{ secrets.OSS_ENDPOINT }} \
90+
-i ${{ secrets.OSS_ACCESS_KEY_ID }} \
91+
-k ${{ secrets.OSS_ACCESS_KEY_SECRET }} \
92+
$template_name.tar \
93+
oss://${{ secrets.OSS_BUCKET }}/cloud/template/arm64/$template_name.tar

.github/workflows/build-all-template-cluster-image.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
else
6363
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
6464
fi
65-
sudo bash scripts/build-cluster-image.sh ${{ matrix.target }} ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest
65+
sudo bash scripts/build-cluster-image.sh ${{ matrix.target }} ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest-amd64
6666
#https://github.com/labring/sealos/issues/6112
6767
- name: Login to ghcr.io
6868
run: |
@@ -75,10 +75,10 @@ jobs:
7575
else
7676
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
7777
fi
78-
sudo sealos push ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest
79-
sudo sealos save ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest -o $template_name.tar
78+
sudo sealos push ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest-amd64
79+
sudo sealos save ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest-amd64 -o $template_name.tar
8080
- name: Upload cluster image tar
81-
if: github.repository_owner == 'labring-actions'
81+
if: github.repository_owner == 'labring-sigs'
8282
run: |
8383
sudo -v ; curl https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash
8484
if [[ $(basename ${{ matrix.target }}) == "index.yaml" ]]; then

.github/workflows/build-template-cluster-image.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ jobs:
2727
- name: List all changed files
2828
run: echo ${{ steps.changed-files.outputs.all_changed_files }}
2929
build:
30-
runs-on: ubuntu-latest
30+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
3131
permissions:
3232
contents: read
3333
packages: write
3434
needs: gen-targets
3535
strategy:
3636
matrix:
3737
target: ${{ fromJSON(needs.gen-targets.outputs.targets) }}
38+
arch: [ amd64, arm64 ]
3839
fail-fast: false
3940
steps:
4041
- name: Free Disk Space (Ubuntu)
@@ -67,7 +68,8 @@ jobs:
6768
else
6869
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
6970
fi
70-
sudo bash scripts/build-cluster-image.sh ${{ matrix.target }} ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest
71+
image_tag=latest-${{ matrix.arch }}
72+
sudo bash scripts/build-cluster-image.sh ${{ matrix.target }} ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:$image_tag
7173
#https://github.com/labring/sealos/issues/6112
7274
- name: Login to ghcr.io
7375
run: |
@@ -80,19 +82,24 @@ jobs:
8082
else
8183
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
8284
fi
83-
sudo sealos push ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest
84-
sudo sealos save ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:latest -o $template_name.tar
85+
image_tag=latest-${{ matrix.arch }}
86+
sudo sealos push ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:$image_tag
87+
sudo sealos save ghcr.io/${{ github.repository }}/sealos-cloud-template-$template_name:$image_tag -o $template_name.tar
8588
- name: Upload cluster image tar
86-
if: github.repository_owner == 'labring-actions'
89+
if: github.repository_owner == 'labring-sigs'
8790
run: |
8891
sudo -v ; curl https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash
8992
if [[ $(basename ${{ matrix.target }}) == "index.yaml" ]]; then
9093
template_name=$(basename $(dirname ${{ matrix.target }}) | tr '[:upper:]' '[:lower:]')
9194
else
9295
template_name=$(basename ${{ matrix.target }} .yaml | tr '[:upper:]' '[:lower:]')
9396
fi
97+
upload_dir="cloud/template"
98+
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
99+
upload_dir="cloud/template/arm64"
100+
fi
94101
ossutil64 cp -f -e ${{ secrets.OSS_ENDPOINT }} \
95102
-i ${{ secrets.OSS_ACCESS_KEY_ID }} \
96103
-k ${{ secrets.OSS_ACCESS_KEY_SECRET }} \
97104
$template_name.tar \
98-
oss://${{ secrets.OSS_BUCKET }}/cloud/template/$template_name.tar
105+
oss://${{ secrets.OSS_BUCKET }}/$upload_dir/$template_name.tar

0 commit comments

Comments
 (0)