|
| 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 |
0 commit comments