docker.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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@v2
  32. - name: Test Build
  33. id: build
  34. uses: docker/build-push-action@v3
  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. && github.repository == 'netdata/netdata'
  63. }}
  64. docker-ci:
  65. if: github.event_name != 'workflow_dispatch'
  66. name: Docker Alt Arch Builds
  67. needs: docker-test
  68. runs-on: ubuntu-latest
  69. strategy:
  70. matrix:
  71. platforms:
  72. - linux/i386
  73. - linux/arm/v7
  74. - linux/arm64
  75. - linux/ppc64le
  76. steps:
  77. - name: Checkout
  78. id: checkout
  79. uses: actions/checkout@v3
  80. with:
  81. submodules: recursive
  82. - name: Setup QEMU
  83. id: qemu
  84. if: matrix.platforms != 'linux/i386'
  85. uses: docker/setup-qemu-action@v2
  86. - name: Setup Buildx
  87. id: buildx
  88. uses: docker/setup-buildx-action@v2
  89. - name: Build
  90. id: build
  91. uses: docker/build-push-action@v3
  92. with:
  93. platforms: ${{ matrix.platforms }}
  94. load: false
  95. push: false
  96. tags: netdata/netdata:test
  97. - name: Failure Notification
  98. uses: rtCamp/action-slack-notify@v2
  99. env:
  100. SLACK_COLOR: 'danger'
  101. SLACK_FOOTER: ''
  102. SLACK_ICON_EMOJI: ':github-actions:'
  103. SLACK_TITLE: 'Docker build testing failed:'
  104. SLACK_USERNAME: 'GitHub Actions'
  105. SLACK_MESSAGE: |-
  106. ${{ github.repository }}: Building Docker image for ${{ matrix.platforms }} failed.
  107. CHeckout: ${{ steps.checkout.outcome }}
  108. Setup QEMU: ${{ steps.qemu.outcome }}
  109. Setup buildx: ${{ steps.buildx.outcome }}
  110. Build image: ${{ steps.build.outcome }}
  111. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  112. if: >-
  113. ${{
  114. failure()
  115. && github.event_name != 'pull_request'
  116. && startsWith(github.ref, 'refs/heads/master')
  117. && github.repository == 'netdata/netdata'
  118. }}
  119. normalize-tag: # Fix the release tag if needed
  120. name: Normalize Release Tag
  121. runs-on: ubuntu-latest
  122. if: github.event_name == 'workflow_dispatch'
  123. outputs:
  124. tag: ${{ steps.tag.outputs.tag }}
  125. steps:
  126. - name: Normalize Tag
  127. id: tag
  128. run: |
  129. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  130. echo "::set-output name=tag::v${{ github.event.inputs.version }}"
  131. else
  132. echo "::set-output name=tag::${{ github.event.inputs.version }}"
  133. fi
  134. docker-publish:
  135. if: github.event_name == 'workflow_dispatch'
  136. name: Docker Build and Publish
  137. needs:
  138. - docker-test
  139. - normalize-tag
  140. runs-on: ubuntu-latest
  141. steps:
  142. - name: Checkout
  143. id: checkout
  144. uses: actions/checkout@v3
  145. with:
  146. submodules: recursive
  147. - name: Determine which tags to use
  148. id: release-tags
  149. if: github.event.inputs.version != 'nightly'
  150. run: |
  151. echo "tags=netdata/netdata:latest,netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '')" \
  152. >> "${GITHUB_ENV}"
  153. - name: Determine which tags to use
  154. id: nightly-tags
  155. if: github.event.inputs.version == 'nightly'
  156. run: |
  157. echo "tags=netdata/netdata:latest,netdata/netdata:edge" >> "${GITHUB_ENV}"
  158. - name: Mark image as official
  159. id: env
  160. if: github.repository == 'netdata/netdata'
  161. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  162. - name: Setup QEMU
  163. id: qemu
  164. uses: docker/setup-qemu-action@v2
  165. - name: Setup Buildx
  166. id: buildx
  167. uses: docker/setup-buildx-action@v2
  168. - name: Docker Hub Login
  169. id: login
  170. if: github.repository == 'netdata/netdata'
  171. uses: docker/login-action@v2
  172. with:
  173. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  174. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  175. - name: Docker Build
  176. id: build
  177. uses: docker/build-push-action@v3
  178. with:
  179. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  180. push: ${{ github.repository == 'netdata/netdata' }}
  181. tags: ${{ env.tags }}
  182. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  183. - name: Failure Notification
  184. uses: rtCamp/action-slack-notify@v2
  185. env:
  186. SLACK_COLOR: 'danger'
  187. SLACK_FOOTER: ''
  188. SLACK_ICON_EMOJI: ':github-actions:'
  189. SLACK_TITLE: 'Docker Build failed:'
  190. SLACK_USERNAME: 'GitHub Actions'
  191. SLACK_MESSAGE: |-
  192. ${{ github.repository }}: Failed to build or publish Docker images.
  193. CHeckout: ${{ steps.checkout.outcome }}
  194. Generate release tags: ${{ steps.release-tags.outcome }}
  195. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  196. Setup environment: ${{ steps.env.outcome }}
  197. Setup QEMU: ${{ steps.qemu.outcome }}
  198. Setup buildx: ${{ steps.buildx.outcome }}
  199. Authenticate against DockerHub: ${{ steps.login.outcome }}
  200. Build and publish images: ${{ steps.build.outcome }}
  201. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  202. if: >-
  203. ${{
  204. failure()
  205. && github.event_name != 'pull_request'
  206. && startsWith(github.ref, 'refs/heads/master')
  207. && github.repository == 'netdata/netdata'
  208. }}
  209. - name: Trigger Helmchart PR
  210. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  211. uses: benc-uk/workflow-dispatch@v1
  212. with:
  213. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  214. repo: netdata/helmchart
  215. workflow: Agent Version PR
  216. ref: refs/heads/master
  217. inputs: '{"agent_version": "${{ needs.normalize-tag.outputs.tag }}"}'
  218. docker-dbg-publish:
  219. if: github.event_name == 'workflow_dispatch'
  220. name: Docker Build and Publish (Debuging Image)
  221. needs:
  222. - docker-test
  223. - normalize-tag
  224. runs-on: ubuntu-latest
  225. steps:
  226. - name: Checkout
  227. id: checkout
  228. uses: actions/checkout@v3
  229. with:
  230. submodules: recursive
  231. - name: Determine which tags to use
  232. id: release-tags
  233. if: github.event.inputs.version != 'nightly'
  234. run: |
  235. echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '-debug')" \
  236. >> "${GITHUB_ENV}"
  237. - name: Determine which tags to use
  238. id: nightly-tags
  239. if: github.event.inputs.version == 'nightly'
  240. run: |
  241. echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:edge" >> "${GITHUB_ENV}"
  242. - name: Mark image as official
  243. id: env
  244. if: github.repository == 'netdata/netdata'
  245. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  246. - name: Setup QEMU
  247. id: qemu
  248. uses: docker/setup-qemu-action@v2
  249. - name: Setup Buildx
  250. id: buildx
  251. uses: docker/setup-buildx-action@v2
  252. - name: Docker Hub Login
  253. id: login
  254. if: github.repository == 'netdata/netdata'
  255. uses: docker/login-action@v2
  256. with:
  257. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  258. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  259. - name: Docker Build
  260. id: build
  261. uses: docker/build-push-action@v3
  262. with:
  263. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  264. push: ${{ github.repository == 'netdata/netdata' }}
  265. tags: ${{ env.tags }}
  266. build-args: |
  267. OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  268. DEBUG_BUILD=1
  269. - name: Failure Notification
  270. uses: rtCamp/action-slack-notify@v2
  271. env:
  272. SLACK_COLOR: 'danger'
  273. SLACK_FOOTER: ''
  274. SLACK_ICON_EMOJI: ':github-actions:'
  275. SLACK_TITLE: 'Docker Debug Build failed:'
  276. SLACK_USERNAME: 'GitHub Actions'
  277. SLACK_MESSAGE: |-
  278. ${{ github.repository }}: Failed to build or publish Docker debug images.
  279. CHeckout: ${{ steps.checkout.outcome }}
  280. Generate release tags: ${{ steps.release-tags.outcome }}
  281. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  282. Setup environment: ${{ steps.env.outcome }}
  283. Setup QEMU: ${{ steps.qemu.outcome }}
  284. Setup buildx: ${{ steps.buildx.outcome }}
  285. Authenticate against DockerHub: ${{ steps.login.outcome }}
  286. Build and publish images: ${{ steps.build.outcome }}
  287. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  288. if: >-
  289. ${{
  290. failure()
  291. && github.event_name != 'pull_request'
  292. && startsWith(github.ref, 'refs/heads/master')
  293. && github.repository == 'netdata/netdata'
  294. }}