docker.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. ---
  2. name: Docker
  3. on:
  4. push:
  5. branches:
  6. - master
  7. pull_request: null
  8. workflow_dispatch:
  9. inputs:
  10. version:
  11. description: Version Tag
  12. default: nightly
  13. required: true
  14. env:
  15. DISABLE_TELEMETRY: 1
  16. concurrency:
  17. group: docker-${{ github.ref }}-${{ github.event_name }}
  18. cancel-in-progress: true
  19. jobs:
  20. docker-test:
  21. name: Docker Runtime Test
  22. runs-on: ubuntu-latest
  23. steps:
  24. - name: Checkout
  25. id: checkout
  26. uses: actions/checkout@v3
  27. with:
  28. submodules: recursive
  29. - name: Setup Buildx
  30. id: prepare
  31. uses: docker/setup-buildx-action@v1
  32. - name: Test Build
  33. id: build
  34. uses: docker/build-push-action@v2
  35. with:
  36. load: true
  37. push: false
  38. tags: netdata/netdata:test
  39. - name: Test Image
  40. id: test
  41. run: .github/scripts/docker-test.sh
  42. - name: Failure Notification
  43. uses: rtCamp/action-slack-notify@v2
  44. env:
  45. SLACK_COLOR: 'danger'
  46. SLACK_FOOTER: ''
  47. SLACK_ICON_EMOJI: ':github-actions:'
  48. SLACK_TITLE: 'Docker runtime testing failed:'
  49. SLACK_USERNAME: 'GitHub Actions'
  50. SLACK_MESSAGE: |-
  51. ${{ github.repository }}: Building or testing Docker image for linux/amd64 failed.
  52. CHeckout: ${{ steps.checkout.outcome }}
  53. Setup buildx: ${{ steps.prepare.outcome }}
  54. Build image: ${{ steps.build.outcome }}
  55. Test image: ${{ steps.test.outcome }}
  56. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  57. if: >-
  58. ${{
  59. failure()
  60. && github.event_name != 'pull_request'
  61. && startsWith(github.ref, 'refs/heads/master')
  62. }}
  63. docker-ci:
  64. if: github.event_name != 'workflow_dispatch'
  65. name: Docker Alt Arch Builds
  66. needs: docker-test
  67. runs-on: ubuntu-latest
  68. strategy:
  69. matrix:
  70. platforms:
  71. - linux/i386
  72. - linux/arm/v7
  73. - linux/arm64
  74. - linux/ppc64le
  75. steps:
  76. - name: Checkout
  77. id: checkout
  78. uses: actions/checkout@v3
  79. with:
  80. submodules: recursive
  81. - name: Setup QEMU
  82. id: qemu
  83. if: matrix.platforms != 'linux/i386'
  84. uses: docker/setup-qemu-action@v1
  85. - name: Setup Buildx
  86. id: buildx
  87. uses: docker/setup-buildx-action@v1
  88. - name: Build
  89. id: build
  90. uses: docker/build-push-action@v2
  91. with:
  92. platforms: ${{ matrix.platforms }}
  93. load: false
  94. push: false
  95. tags: netdata/netdata:test
  96. - name: Failure Notification
  97. uses: rtCamp/action-slack-notify@v2
  98. env:
  99. SLACK_COLOR: 'danger'
  100. SLACK_FOOTER: ''
  101. SLACK_ICON_EMOJI: ':github-actions:'
  102. SLACK_TITLE: 'Docker build testing failed:'
  103. SLACK_USERNAME: 'GitHub Actions'
  104. SLACK_MESSAGE: |-
  105. ${{ github.repository }}: Building Docker image for ${{ matrix.platforms }} failed.
  106. CHeckout: ${{ steps.checkout.outcome }}
  107. Setup QEMU: ${{ steps.qemu.outcome }}
  108. Setup buildx: ${{ steps.buildx.outcome }}
  109. Build image: ${{ steps.build.outcome }}
  110. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  111. if: >-
  112. ${{
  113. failure()
  114. && github.event_name != 'pull_request'
  115. && startsWith(github.ref, 'refs/heads/master')
  116. }}
  117. normalize-tag: # Fix the release tag if needed
  118. name: Normalize Release Tag
  119. runs-on: ubuntu-latest
  120. if: github.event_name == 'workflow_dispatch'
  121. outputs:
  122. tag: ${{ steps.tag.outputs.tag }}
  123. steps:
  124. - name: Normalize Tag
  125. id: tag
  126. run: |
  127. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  128. echo "::set-output name=tag::v${{ github.event.inputs.version }}"
  129. else
  130. echo "::set-output name=tag::${{ github.event.inputs.version }}"
  131. fi
  132. docker-publish:
  133. if: github.event_name == 'workflow_dispatch'
  134. name: Docker Build and Publish
  135. needs:
  136. - docker-test
  137. - normalize-tag
  138. runs-on: ubuntu-latest
  139. steps:
  140. - name: Checkout
  141. id: checkout
  142. uses: actions/checkout@v3
  143. with:
  144. submodules: recursive
  145. - name: Determine which tags to use
  146. id: release-tags
  147. if: github.event.inputs.version != 'nightly'
  148. run: |
  149. echo "tags=netdata/netdata:latest,netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }})" \
  150. >> "${GITHUB_ENV}"
  151. - name: Determine which tags to use
  152. id: nightly-tags
  153. if: github.event.inputs.version == 'nightly'
  154. run: |
  155. echo "tags=netdata/netdata:latest,netdata/netdata:edge" >> "${GITHUB_ENV}"
  156. - name: Mark image as official
  157. id: env
  158. if: github.repository == 'netdata/netdata'
  159. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  160. - name: Setup QEMU
  161. id: qemu
  162. uses: docker/setup-qemu-action@v1
  163. - name: Setup Buildx
  164. id: buildx
  165. uses: docker/setup-buildx-action@v1
  166. - name: Docker Hub Login
  167. id: login
  168. uses: docker/login-action@v1
  169. with:
  170. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  171. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  172. - name: Docker Build
  173. id: build
  174. uses: docker/build-push-action@v2
  175. with:
  176. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  177. push: true
  178. tags: ${{ env.tags }}
  179. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  180. - name: Failure Notification
  181. uses: rtCamp/action-slack-notify@v2
  182. env:
  183. SLACK_COLOR: 'danger'
  184. SLACK_FOOTER: ''
  185. SLACK_ICON_EMOJI: ':github-actions:'
  186. SLACK_TITLE: 'Docker Build failed:'
  187. SLACK_USERNAME: 'GitHub Actions'
  188. SLACK_MESSAGE: |-
  189. ${{ github.repository }}: Failed to build or publish Docker images.
  190. CHeckout: ${{ steps.checkout.outcome }}
  191. Generate release tags: ${{ steps.release-tags.outcome }}
  192. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  193. Setup environment: ${{ steps.env.outcome }}
  194. Setup QEMU: ${{ steps.qemu.outcome }}
  195. Setup buildx: ${{ steps.buildx.outcome }}
  196. Authenticate against DockerHub: ${{ steps.login.outcome }}
  197. Build and publish images: ${{ steps.build.outcome }}
  198. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  199. if: >-
  200. ${{
  201. failure()
  202. && github.event_name != 'pull_request'
  203. && startsWith(github.ref, 'refs/heads/master')
  204. }}
  205. - name: Trigger Helmchart PR
  206. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly'
  207. uses: benc-uk/workflow-dispatch@v1
  208. with:
  209. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  210. repo: netdata/helmchart
  211. workflow: Agent Version PR
  212. ref: refs/heads/master
  213. inputs: '{"agent_version": "${{ needs.normalize-tag.outputs.tag }}"}'