summaryrefslogtreecommitdiffstats
path: root/.github/workflows/docker.yml
blob: 78a39d5a2869c01d19e828541291566cf5b6945d (plain)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
---
name: Docker
on:
  push:
    branches:
      - master
  pull_request: null
  workflow_dispatch:
    inputs:
      version:
        description: Version Tag
        default: nightly
        required: true
env:
  DISABLE_TELEMETRY: 1
concurrency:
  group: docker-${{ github.ref }}-${{ github.event_name }}
  cancel-in-progress: true
jobs:
  docker-test:
    name: Docker Runtime Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Setup Buildx
        id: prepare
        uses: docker/setup-buildx-action@v2
      - name: Test Build
        id: build
        uses: docker/build-push-action@v3
        with:
          load: true
          push: false
          tags: netdata/netdata:test
      - name: Test Image
        id: test
        run: .github/scripts/docker-test.sh
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Docker runtime testing failed:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Building or testing Docker image for linux/amd64 failed.
              CHeckout: ${{ steps.checkout.outcome }}
              Setup buildx: ${{ steps.prepare.outcome }}
              Build image: ${{ steps.build.outcome }}
              Test image: ${{ steps.test.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: >-
          ${{
            failure()
            && github.event_name != 'pull_request'
            && startsWith(github.ref, 'refs/heads/master')
            && github.repository == 'netdata/netdata'
          }}

  docker-ci:
    if: github.event_name != 'workflow_dispatch'
    name: Docker Alt Arch Builds
    needs: docker-test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platforms:
          - linux/i386
          - linux/arm/v7
          - linux/arm64
          - linux/ppc64le
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Setup QEMU
        id: qemu
        if: matrix.platforms != 'linux/i386'
        uses: docker/setup-qemu-action@v2
      - name: Setup Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
      - name: Build
        id: build
        uses: docker/build-push-action@v3
        with:
          platforms: ${{ matrix.platforms }}
          load: false
          push: false
          tags: netdata/netdata:test
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Docker build testing failed:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Building Docker image for ${{ matrix.platforms }} failed.
              CHeckout: ${{ steps.checkout.outcome }}
              Setup QEMU: ${{ steps.qemu.outcome }}
              Setup buildx: ${{ steps.buildx.outcome }}
              Build image: ${{ steps.build.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: >-
          ${{
            failure()
            && github.event_name != 'pull_request'
            && startsWith(github.ref, 'refs/heads/master')
            && github.repository == 'netdata/netdata'
          }}

  normalize-tag: # Fix the release tag if needed
    name: Normalize Release Tag
    runs-on: ubuntu-latest
    if: github.event_name == 'workflow_dispatch'
    outputs:
      tag: ${{ steps.tag.outputs.tag }}
    steps:
      - name: Normalize Tag
        id: tag
        run: |
          if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
            echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
          else
            echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
          fi

  docker-publish:
    if: github.event_name == 'workflow_dispatch'
    name: Docker Build and Publish
    needs:
      - docker-test
      - normalize-tag
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Determine which tags to use
        id: release-tags
        if: github.event.inputs.version != 'nightly'
        run: |
          echo "tags=netdata/netdata:latest,netdata/netdata:stable,ghcr.io/netdata/netdata:latest,ghcr.io/netdata/netdata:stable,quay.io/netdata/netdata:latest,quay.io/netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '')" \
              >> "${GITHUB_ENV}"
      - name: Determine which tags to use
        id: nightly-tags
        if: github.event.inputs.version == 'nightly'
        run: |
          echo "tags=netdata/netdata:latest,netdata/netdata:edge,ghcr.io/netdata/netdata:latest,ghcr.io/netdata/netdata:edge,quay.io/netdata/netdata:latest,quay.io/netdata/netdata:edge" >> "${GITHUB_ENV}"
      - name: Mark image as official
        id: env
        if: github.repository == 'netdata/netdata'
        run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
      - name: Setup QEMU
        id: qemu
        uses: docker/setup-qemu-action@v2
      - name: Setup Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
      - name: Docker Hub Login
        id: docker-hub-login
        if: github.repository == 'netdata/netdata'
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_HUB_USERNAME }}
          password: ${{ secrets.DOCKER_HUB_PASSWORD }}
      - name: GitHub Container Registry Login
        id: ghcr-login
        if: github.repository == 'netdata/netdata'
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Quay.io Login
        id: quay-login
        if: github.repository == 'netdata/netdata'
        uses: docker/login-action@v2
        with:
          registry: quay.io
          username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
          password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
      - name: Docker Build
        id: build
        uses: docker/build-push-action@v3
        with:
          platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
          push: ${{ github.repository == 'netdata/netdata' }}
          tags: ${{ env.tags }}
          build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Docker Build failed:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to build or publish Docker images.
              CHeckout: ${{ steps.checkout.outcome }}
              Generate release tags: ${{ steps.release-tags.outcome }}
              Generate nightly tags: ${{ steps.nightly-tags.outcome }}
              Setup environment: ${{ steps.env.outcome }}
              Setup QEMU: ${{ steps.qemu.outcome }}
              Setup buildx: ${{ steps.buildx.outcome }}
              Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
              Login to GHCR: ${{ steps.ghcr-login.outcome }}
              Login to Quay: ${{ steps.quay-login.outcome }}
              Build and publish images: ${{ steps.build.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: >-
          ${{
            failure()
            && github.event_name != 'pull_request'
            && startsWith(github.ref, 'refs/heads/master')
            && github.repository == 'netdata/netdata'
          }}
      - name: Trigger Helmchart PR
        if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
        uses: benc-uk/workflow-dispatch@v1
        with:
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          repo: netdata/helmchart
          workflow: Agent Version PR
          ref: refs/heads/master
          inputs: '{"agent_version": "${{ needs.normalize-tag.outputs.tag }}"}'

  docker-dbg-publish:
    if: github.event_name == 'workflow_dispatch'
    name: Docker Build and Publish (Debugging Image)
    needs:
      - docker-test
      - normalize-tag
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Determine which tags to use
        id: release-tags
        if: github.event.inputs.version != 'nightly'
        run: |
          echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:stable,ghcr.io/netdata/netdata-debug:latest,ghcr.io/netdata/netdata-debug:stable,quay.io/netdata/netdata-debug:latest,quay.io/netdata/netdata-debug:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '-debug')" \
              >> "${GITHUB_ENV}"
      - name: Determine which tags to use
        id: nightly-tags
        if: github.event.inputs.version == 'nightly'
        run: |
          echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:edge,ghcr.io/netdata/netdata-debug:latest,ghcr.io/netdata/netdata-debug:edge,quay.io/netdata/netdata-debug:latest,quay.io/netdata/netdata-debug:edge" >> "${GITHUB_ENV}"
      - name: Mark image as official
        id: env
        if: github.repository == 'netdata/netdata'
        run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
      - name: Setup QEMU
        id: qemu
        uses: docker/setup-qemu-action@v2
      - name: Setup Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
      - name: Docker Hub Login
        id: docker-hub-login
        if: github.repository == 'netdata/netdata'
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_HUB_USERNAME }}
          password: ${{ secrets.DOCKER_HUB_PASSWORD }}
      - name: GitHub Container Registry Login
        id: ghcr-login
        if: github.repository == 'netdata/netdata'
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Quay.io Login
        id: quay-login
        if: github.repository == 'netdata/netdata'
        uses: docker/login-action@v2
        with:
          registry: quay.io
          username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
          password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
      - name: Docker Build
        id: build
        uses: docker/build-push-action@v3
        with:
          platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
          push: ${{ github.repository == 'netdata/netdata' }}
          tags: ${{ env.tags }}
          build-args: |
            OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
            DEBUG_BUILD=1
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Docker Debug Build failed:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to build or publish Docker debug images.
              Checkout: ${{ steps.checkout.outcome }}
              Generate release tags: ${{ steps.release-tags.outcome }}
              Generate nightly tags: ${{ steps.nightly-tags.outcome }}
              Setup environment: ${{ steps.env.outcome }}
              Setup QEMU: ${{ steps.qemu.outcome }}
              Setup buildx: ${{ steps.buildx.outcome }}
              Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
              Login to GHCR: ${{ steps.ghcr-login.outcome }}
              Login to Quay: ${{ steps.quay-login.outcome }}
              Build and publish images: ${{ steps.build.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: >-
          ${{
            failure()
            && github.event_name != 'pull_request'
            && startsWith(github.ref, 'refs/heads/master')
            && github.repository == 'netdata/netdata'
          }}