1
+ name : build-image
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - " *"
7
+ tags :
8
+ - " v*"
9
+
10
+ jobs :
11
+ buildx :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - uses : actions/checkout@v2
15
+ with :
16
+ submodules : true
17
+
18
+ - uses : actions/setup-go@v2
19
+ with :
20
+ go-version : ^1.15
21
+
22
+ - uses : docker/setup-qemu-action@v1
23
+ - uses : docker/setup-buildx-action@v1
24
+ with :
25
+ driver-opts : network=host
26
+
27
+ - id : prepare
28
+ name : Build binaries && Prepare
29
+ env :
30
+ GITHUB_REF : ${{ github.sha }}
31
+ GITHUB_SHA : ${{ github.ref }}
32
+ # for other platforms support only need to updates
33
+ TARGET_PLATFORMS : linux/amd64,linux/arm64
34
+ TARGET_ARCHS : amd64 arm64
35
+ run : |-
36
+ make code/compilex TARGET_ARCHS="${TARGET_ARCHS}" COMPILE_TARGET=./build/_output/bin/grafana-operator
37
+
38
+ file build/_output/bin/*
39
+
40
+ export TAG=${GITHUB_SHA::7}
41
+
42
+ if [[ ${{ github.ref }} == "refs/tags/v"* ]]; then
43
+ TAG=$(echo ${{ github.ref }} | sed -e "s/refs\/tags\///")
44
+ fi
45
+
46
+ echo ::set-output name=target_platforms::${TARGET_PLATFORMS}
47
+ echo ::set-output name=tag::${TAG}
48
+
49
+ - uses : docker/login-action@v1
50
+ name : Login docker.io
51
+ with :
52
+ password : ${{ secrets.DOCKER_PASSWORD }}
53
+ registry : docker.io
54
+ username : ${{ secrets.DOCKER_USERNAME }}
55
+
56
+ - uses : docker/login-action@v1
57
+ name : Login quay.io
58
+ with :
59
+ password : ${{ secrets.QUAY_PASSWORD }}
60
+ registry : quay.io
61
+ username : ${{ secrets.QUAY_USERNAME }}
62
+
63
+ - uses : docker/build-push-action@v2
64
+ name : Build image && May Push
65
+ with :
66
+ file : build/Dockerfile
67
+ context : .
68
+ labels : |-
69
+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
70
+ org.opencontainers.image.revision=${{ github.sha }}
71
+ platforms : ${{ steps.prepare.outputs.target_platforms }}
72
+ push : ${{ github.event_name != 'pull_request' }}
73
+ tags : |
74
+ docker.io/${{ github.repository }}:${{ steps.prepare.outputs.tag }}
75
+ quay.io/integreatly/grafana-operator:${{ steps.prepare.outputs.tag }}
0 commit comments