docker.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ---
  2. name: Docker
  3. on:
  4. push:
  5. branches:
  6. - master
  7. pull_request:
  8. workflow_dispatch:
  9. inputs:
  10. version:
  11. name: Version Tag
  12. default: nightly
  13. required: true
  14. jobs:
  15. docker-build:
  16. name: Docker Build
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Checkout
  20. uses: actions/checkout@v2
  21. with:
  22. submodules: recursive
  23. - name: Determine if we should push changes and which tags to use
  24. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly'
  25. run: |
  26. echo "publish=true" >> $GITHUB_ENV
  27. echo "tags=netdata/netdata:latest,netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ github.event.inputs.version }})" >> $GITHUB_ENV
  28. - name: Determine if we should push changes and which tags to use
  29. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version == 'nightly'
  30. run: |
  31. echo "publish=true" >> $GITHUB_ENV
  32. echo "tags=netdata/netdata:latest,netdata/netdata:edge" >> $GITHUB_ENV
  33. - name: Determine if we should push changes and which tags to use
  34. if: github.event_name != 'workflow_dispatch'
  35. run: |
  36. echo "publish=false" >> $GITHUB_ENV
  37. echo "tags=netdata/netdata:test" >> $GITHUB_ENV
  38. - name: Setup QEMU
  39. uses: docker/setup-qemu-action@v1
  40. - name: Setup Buildx
  41. uses: docker/setup-buildx-action@v1
  42. - name: Docker Hub Login
  43. if: github.event_name == 'workflow_dispatch'
  44. uses: docker/login-action@v1
  45. with:
  46. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  47. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  48. - name: Docker Build
  49. uses: docker/build-push-action@v2
  50. with:
  51. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64
  52. push: ${{ env.publish }}
  53. tags: ${{ env.tags }}
  54. - name: Failure Notification
  55. uses: rtCamp/action-slack-notify@v2
  56. env:
  57. SLACK_COLOR: 'danger'
  58. SLACK_FOOTER:
  59. SLACK_ICON_EMOJI: ':github-actions:'
  60. SLACK_TITLE: 'Docker Build failed:'
  61. SLACK_USERNAME: 'GitHub Actions'
  62. SLACK_MESSAGE: "Docker image build failed."
  63. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  64. if: >-
  65. ${{
  66. failure()
  67. && github.event_name != 'pull_request'
  68. && startsWith(github.ref, 'refs/heads/master')
  69. }}