summaryrefslogtreecommitdiffstats
path: root/.github/workflows/docker.yml
blob: f8a1d68554925637ed8221ad01ddf338d68beb09 (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
---
name: Docker
on:
  push:
    branches:
      - master
  pull_request: null
  workflow_dispatch:
    inputs:
      version:
        name: Version Tag
        default: nightly
        required: true
env:
  DO_NOT_TRACK: 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
        uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Setup Buildx
        uses: docker/setup-buildx-action@v1
      - name: Test Build
        uses: docker/build-push-action@v2
        with:
          load: true
          push: false
          tags: netdata/netdata:test
      - name: Test Image
        run: .github/scripts/docker-test.sh

  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
        uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Setup QEMU
        if: matrix.platforms != 'linux/i386'
        uses: docker/setup-qemu-action@v1
      - name: Setup Buildx
        uses: docker/setup-buildx-action@v1
      - name: Build
        uses: docker/build-push-action@v2
        with:
          platforms: ${{ matrix.platforms }}
          load: false
          push: false
          tags: netdata/netdata:test

  docker-publish:
    if: github.event_name == 'workflow_dispatch'
    name: Docker Build and Publish
    needs: docker-test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Determine which tags to use
        if: github.event.inputs.version != 'nightly'
        run: |
          echo "tags=netdata/netdata:latest,netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ github.event.inputs.version }})" >> $GITHUB_ENV
      - name: Determine which tags to use
        if: github.event.inputs.version == 'nightly'
        run: |
          echo "tags=netdata/netdata:latest,netdata/netdata:edge" >> $GITHUB_ENV
      - name: Mark image as official
        if: github.repository == 'netdata/netdata'
        run: echo "OFFICIAL_IMAGE=true" >> $GITHUB_ENV
      - name: Setup QEMU
        uses: docker/setup-qemu-action@v1
      - name: Setup Buildx
        uses: docker/setup-buildx-action@v1
      - name: Docker Hub Login
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_HUB_USERNAME }}
          password: ${{ secrets.DOCKER_HUB_PASSWORD }}
      - name: Docker Build
        uses: docker/build-push-action@v2
        with:
          platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
          push: true
          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: "Docker image build failed."
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: >-
          ${{
            failure()
            && github.event_name != 'pull_request'
            && startsWith(github.ref, 'refs/heads/master')
          }}
      - name: Trigger Helmchart PR
        if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly'
        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": "${{ github.event.inputs.version }}"}'