summaryrefslogtreecommitdiffstats
path: root/.github/workflows/docker.yml
blob: a5648d2a93f25554232fdbc40df812f3a17ed16e (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
---
name: Docker
on:
  push:
    branches:
      - master
  pull_request:
  workflow_dispatch:
    inputs:
      version:
        name: Version Tag
        default: nightly
        required: true
jobs:
  docker-build:
    name: Docker Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Determine if we should push changes and which tags to use
        if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly'
        run: |
          echo "publish=true" >> $GITHUB_ENV
          echo "tags=netdata/netdata:latest,netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ github.event.inputs.version }})" >> $GITHUB_ENV
      - name: Determine if we should push changes and which tags to use
        if: github.event_name == 'workflow_dispatch' && github.event.inputs.version == 'nightly'
        run: |
          echo "publish=true" >> $GITHUB_ENV
          echo "tags=netdata/netdata:latest,netdata/netdata:edge" >> $GITHUB_ENV
      - name: Determine if we should push changes and which tags to use
        if: github.event_name != 'workflow_dispatch'
        run: |
          echo "publish=false" >> $GITHUB_ENV
          echo "tags=netdata/netdata:test" >> $GITHUB_ENV
      - name: Setup QEMU
        uses: docker/setup-qemu-action@v1
      - name: Setup Buildx
        uses: docker/setup-buildx-action@v1
      - name: Docker Hub Login
        if: github.event_name == 'workflow_dispatch'
        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
          push: ${{ env.publish }}
          tags: ${{ env.tags }}
      - 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')
          }}