-
Notifications
You must be signed in to change notification settings - Fork 5
112 lines (110 loc) · 4.57 KB
/
build.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
name: Build
on:
push:
workflow_dispatch:
schedule:
- cron: '0 1 * * 5'
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
if: >-
${{ !contains(github.event.head_commit.message, '[ci skip]') &&
!contains(github.event.head_commit.message, '[skip ci]')
}}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU dependency
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to the container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract lowercase repository name
uses: ASzc/change-string-case-action@v1
with:
string: ${{ github.repository }}
id: repository
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Build Builder
shell: bash
run: |
export CI_PROJECT_DIR=${PWD}
export CI_REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ steps.repository.outputs.lowercase }}
export BUILDX_PLATFORM=linux/s390x,linux/386,linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6,linux/ppc64le
export CADVISOR_VERSION=$(curl -s https://api.github.com/repos/google/cadvisor/releases | jq -r "[[.[] | select(.draft != true) | select(.prerelease != true)][0]][0].name")
export GO111MODULE=on
export GO_FLAGS="-tags=netgo"
export CGO_ENABLED="0"
export OUTPUT_NAME_WITH_ARCH=false
echo ${CI_REGISTRY_IMAGE}
echo ${BUILDX_PLATFORM}
echo ${CADVISOR_VERSION}
echo #0
docker buildx build --platform=${BUILDX_PLATFORM} --cache-from ${CI_REGISTRY_IMAGE}/cache/builder --cache-to ${CI_REGISTRY_IMAGE}/cache/builder --build-arg CADVISOR_VERSION -f Dockerfile.builder -t ${CI_REGISTRY_IMAGE}/builder --push "."
echo #1
git clone https://github.com/google/cadvisor
cd cadvisor
git checkout $CADVISOR_VERSION
go mod download
./build/assets.sh
go get github.com/Shopify/sarama@latest
go mod tidy
go mod download
go mod vendor
cd cmd
go get github.com/Shopify/sarama@latest
go mod tidy
go mod download
go mod vendor
cd ..
echo step build
cat go.mod
mkdir -p s390x
GOOS=linux GOARCH=s390x ./build/build.sh s390x
mv _output/cadvisor s390x/
mkdir -p 386
GOOS=linux GOARCH=386 ./build/build.sh 386
mv _output/cadvisor 386/
mkdir -p amd64
GOOS=linux GOARCH=amd64 ./build/build.sh amd64
mv _output/cadvisor amd64/
mkdir -p arm64
GOOS=linux GOARCH=arm64 ./build/build.sh arm64
mv _output/cadvisor arm64/
mkdir -p arm/v7
GOOS=linux GOARCH=arm GOARM=7 ./build/build.sh arm
mv _output/cadvisor arm/v7/
mkdir -p arm/v6
GOOS=linux GOARCH=arm GOARM=6 ./build/build.sh arm
mv _output/cadvisor arm/v6/
mkdir -p ppc64le
GOOS=linux GOARCH=ppc64le ./build/build.sh ppc64le
mv _output/cadvisor ppc64le/
go mod vendor
rm -f cadvisor || true
cd ..
tar czf cadvisor.tar.gz cadvisor
cd $(go env GOMODCACHE)/..
tar czf ${CI_PROJECT_DIR}/mod.tar.gz mod
cd -
echo #2
docker buildx build --platform=${BUILDX_PLATFORM} --cache-from ${CI_REGISTRY_IMAGE}/cache/cadvisor:${CADVISOR_VERSION} --cache-to ${CI_REGISTRY_IMAGE}/cache/cadvisor:${CADVISOR_VERSION} --build-arg CADVISOR_VERSION -f Dockerfile.deploy -t ${CI_REGISTRY_IMAGE}/cadvisor:${CADVISOR_VERSION} -t ${CI_REGISTRY_IMAGE}/cadvisor:latest --push "."
skopeo copy --all --dest-creds=zcube:${{ secrets.DOCKER_HUB_KEY }} docker://${CI_REGISTRY_IMAGE}/cadvisor:${CADVISOR_VERSION} docker://zcube/cadvisor:${CADVISOR_VERSION}
skopeo copy --all --dest-creds=zcube:${{ secrets.DOCKER_HUB_KEY }} docker://${CI_REGISTRY_IMAGE}/cadvisor:${CADVISOR_VERSION} docker://zcube/cadvisor:latest