8
8
9
9
jobs :
10
10
11
- build-amd64 :
12
- name : Build amd64 Docker Image
11
+ build-images :
12
+ name : Build Docker Images
13
13
runs-on : ubuntu-latest
14
14
steps :
15
15
# Check out code
@@ -23,123 +23,9 @@ jobs:
23
23
echo ::set-output name=tag::$([[ "${GITHUB_REF##*/}" == "main" ]] && echo latest || echo ${GITHUB_REF##*/})
24
24
id : version
25
25
26
- # Set up a buildx runner
27
- - name : Set up Docker Buildx
28
- uses : docker/setup-buildx-action@v1
29
-
30
- # Set up an Docker layer cache
31
- - name : Cache Docker layers
32
- uses : actions/cache@v2
33
- with :
34
- path : /tmp/.buildx-cache
35
- key : ${{ runner.os }}-amd64-buildx-${{ github.sha }}
36
- restore-keys : |
37
- ${{ runner.os }}-amd64-buildx-
38
-
39
- # Login to the container registry
40
- - name : Login to Container Registry
41
- run : echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
42
- if : ${{ github.event_name != 'pull_request' }}
43
-
44
- - name : Patch buildx multiarch image
45
- run : |
46
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
47
- docker buildx create --name multiarch --driver docker-container --use
48
- docker buildx inspect --bootstrap
49
-
50
- # Build and push the image
51
- - name : Build and Push Controller Image
52
- uses : docker/build-push-action@v2
53
- with :
54
- platforms : linux/amd64
55
- push : ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
56
- tags : ghcr.io/pelotech/jsonnet-controller:${{ steps.version.outputs.tag }}
57
- cache-from : type=local,src=/tmp/.buildx-cache
58
- cache-to : type=local,dest=/tmp/.buildx-cache-new
59
-
60
- # This ugly bit is necessary if you don't want your cache to grow forever
61
- # till it hits GitHub's limit of 5GB.
62
- # Temp fix
63
- # https://github.com/docker/build-push-action/issues/252
64
- # https://github.com/moby/buildkit/issues/1896
65
- - name : Move cache
66
- run : |
67
- rm -rf /tmp/.buildx-cache
68
- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
69
-
70
- build-arm64 :
71
- name : Build arm64 Docker Image
72
- runs-on : ubuntu-latest
73
- steps :
74
- # Check out code
75
- - name : Checkout
76
- uses : actions/checkout@v2
77
-
78
- # Determine tag we will use for images
79
- - name : Get image version
80
- shell : bash
81
- run : |
82
- echo ::set-output name=tag::$([[ "${GITHUB_REF##*/}" == "main" ]] && echo latest || echo ${GITHUB_REF##*/})
83
- id : version
84
-
85
- # Set up a buildx runner
86
- - name : Set up Docker Buildx
87
- uses : docker/setup-buildx-action@v1
88
-
89
- # Set up an Docker layer cache
90
- - name : Cache Docker layers
91
- uses : actions/cache@v2
92
- with :
93
- path : /tmp/.buildx-cache
94
- key : ${{ runner.os }}-arm64-buildx-${{ github.sha }}
95
- restore-keys : |
96
- ${{ runner.os }}-arm64-buildx-
97
-
98
- # Login to the container registry
99
- - name : Login to Container Registry
100
- run : echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
101
- if : ${{ github.event_name != 'pull_request' }}
102
-
103
- - name : Patch buildx multiarch image
104
- run : |
105
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
106
- docker buildx create --name multiarch --driver docker-container --use
107
- docker buildx inspect --bootstrap
108
-
109
- # Build and push the image
110
- - name : Build and Push Controller Image
111
- uses : docker/build-push-action@v2
112
- with :
113
- platforms : linux/arm64
114
- push : ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
115
- tags : ghcr.io/pelotech/jsonnet-controller:${{ steps.version.outputs.tag }}
116
- cache-from : type=local,src=/tmp/.buildx-cache
117
- cache-to : type=local,dest=/tmp/.buildx-cache-new
118
-
119
- # This ugly bit is necessary if you don't want your cache to grow forever
120
- # till it hits GitHub's limit of 5GB.
121
- # Temp fix
122
- # https://github.com/docker/build-push-action/issues/252
123
- # https://github.com/moby/buildkit/issues/1896
124
- - name : Move cache
125
- run : |
126
- rm -rf /tmp/.buildx-cache
127
- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
128
-
129
- build-armv7 :
130
- name : Build armv7 Docker Image
131
- runs-on : ubuntu-latest
132
- steps :
133
- # Check out code
134
- - name : Checkout
135
- uses : actions/checkout@v2
136
-
137
- # Determine tag we will use for images
138
- - name : Get image version
139
- shell : bash
140
- run : |
141
- echo ::set-output name=tag::$([[ "${GITHUB_REF##*/}" == "main" ]] && echo latest || echo ${GITHUB_REF##*/})
142
- id : version
26
+ # Setup QEMU
27
+ - name : Set up QEMU
28
+ uses : docker/setup-qemu-action@v1
143
29
144
30
# Set up a buildx runner
145
31
- name : Set up Docker Buildx
150
36
uses : actions/cache@v2
151
37
with :
152
38
path : /tmp/.buildx-cache
153
- key : ${{ runner.os }}-armv7- buildx-${{ github.sha }}
39
+ key : ${{ runner.os }}-buildx-${{ github.sha }}
154
40
restore-keys : |
155
- ${{ runner.os }}-armv7- buildx-
41
+ ${{ runner.os }}-buildx-
156
42
157
43
# Login to the container registry
158
44
- name : Login to Container Registry
169
55
- name : Build and Push Controller Image
170
56
uses : docker/build-push-action@v2
171
57
with :
172
- platforms : linux/arm/v7
58
+ platforms : linux/amd64,linux/arm64,linux/ arm/v7
173
59
push : ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
174
60
tags : ghcr.io/pelotech/jsonnet-controller:${{ steps.version.outputs.tag }}
175
61
cache-from : type=local,src=/tmp/.buildx-cache
0 commit comments