docker.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  131. else
  132. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  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,ghcr.io/netdata/netdata:latest,ghcr.io/netdata/netdata:stable,quay.io/netdata/netdata:latest,quay.io/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,ghcr.io/netdata/netdata:latest,ghcr.io/netdata/netdata:edge,quay.io/netdata/netdata:latest,quay.io/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: docker-hub-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: GitHub Container Registry Login
  176. id: ghcr-login
  177. if: github.repository == 'netdata/netdata'
  178. uses: docker/login-action@v2
  179. with:
  180. registry: ghcr.io
  181. username: ${{ github.repository_owner }}
  182. password: ${{ secrets.GITHUB_TOKEN }}
  183. - name: Quay.io Login
  184. id: quay-login
  185. if: github.repository == 'netdata/netdata'
  186. uses: docker/login-action@v2
  187. with:
  188. registry: quay.io
  189. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  190. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  191. - name: Docker Build
  192. id: build
  193. uses: docker/build-push-action@v3
  194. with:
  195. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  196. push: ${{ github.repository == 'netdata/netdata' }}
  197. tags: ${{ env.tags }}
  198. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  199. - name: Failure Notification
  200. uses: rtCamp/action-slack-notify@v2
  201. env:
  202. SLACK_COLOR: 'danger'
  203. SLACK_FOOTER: ''
  204. SLACK_ICON_EMOJI: ':github-actions:'
  205. SLACK_TITLE: 'Docker Build failed:'
  206. SLACK_USERNAME: 'GitHub Actions'
  207. SLACK_MESSAGE: |-
  208. ${{ github.repository }}: Failed to build or publish Docker images.
  209. CHeckout: ${{ steps.checkout.outcome }}
  210. Generate release tags: ${{ steps.release-tags.outcome }}
  211. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  212. Setup environment: ${{ steps.env.outcome }}
  213. Setup QEMU: ${{ steps.qemu.outcome }}
  214. Setup buildx: ${{ steps.buildx.outcome }}
  215. Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
  216. Login to GHCR: ${{ steps.ghcr-login.outcome }}
  217. Login to Quay: ${{ steps.quay-login.outcome }}
  218. Build and publish images: ${{ steps.build.outcome }}
  219. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  220. if: >-
  221. ${{
  222. failure()
  223. && github.event_name != 'pull_request'
  224. && startsWith(github.ref, 'refs/heads/master')
  225. && github.repository == 'netdata/netdata'
  226. }}
  227. - name: Trigger Helmchart PR
  228. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  229. uses: benc-uk/workflow-dispatch@v1
  230. with:
  231. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  232. repo: netdata/helmchart
  233. workflow: Agent Version PR
  234. ref: refs/heads/master
  235. inputs: '{"agent_version": "${{ needs.normalize-tag.outputs.tag }}"}'
  236. docker-dbg-publish:
  237. if: github.event_name == 'workflow_dispatch'
  238. name: Docker Build and Publish (Debugging Image)
  239. needs:
  240. - docker-test
  241. - normalize-tag
  242. runs-on: ubuntu-latest
  243. steps:
  244. - name: Checkout
  245. id: checkout
  246. uses: actions/checkout@v3
  247. with:
  248. submodules: recursive
  249. - name: Determine which tags to use
  250. id: release-tags
  251. if: github.event.inputs.version != 'nightly'
  252. run: |
  253. echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:stable,ghcr.io/netdata/netdata-debug:latest,ghcr.io/netdata/netdata-debug:stable,quay.io/netdata/netdata-debug:latest,quay.io/netdata/netdata-debug:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '-debug')" \
  254. >> "${GITHUB_ENV}"
  255. - name: Determine which tags to use
  256. id: nightly-tags
  257. if: github.event.inputs.version == 'nightly'
  258. run: |
  259. echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:edge,ghcr.io/netdata/netdata-debug:latest,ghcr.io/netdata/netdata-debug:edge,quay.io/netdata/netdata-debug:latest,quay.io/netdata/netdata-debug:edge" >> "${GITHUB_ENV}"
  260. - name: Mark image as official
  261. id: env
  262. if: github.repository == 'netdata/netdata'
  263. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  264. - name: Setup QEMU
  265. id: qemu
  266. uses: docker/setup-qemu-action@v2
  267. - name: Setup Buildx
  268. id: buildx
  269. uses: docker/setup-buildx-action@v2
  270. - name: Docker Hub Login
  271. id: docker-hub-login
  272. if: github.repository == 'netdata/netdata'
  273. uses: docker/login-action@v2
  274. with:
  275. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  276. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  277. - name: GitHub Container Registry Login
  278. id: ghcr-login
  279. if: github.repository == 'netdata/netdata'
  280. uses: docker/login-action@v2
  281. with:
  282. registry: ghcr.io
  283. username: ${{ github.repository_owner }}
  284. password: ${{ secrets.GITHUB_TOKEN }}
  285. - name: Quay.io Login
  286. id: quay-login
  287. if: github.repository == 'netdata/netdata'
  288. uses: docker/login-action@v2
  289. with:
  290. registry: quay.io
  291. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  292. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  293. - name: Docker Build
  294. id: build
  295. uses: docker/build-push-action@v3
  296. with:
  297. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  298. push: ${{ github.repository == 'netdata/netdata' }}
  299. tags: ${{ env.tags }}
  300. build-args: |
  301. OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  302. DEBUG_BUILD=1
  303. - name: Failure Notification
  304. uses: rtCamp/action-slack-notify@v2
  305. env:
  306. SLACK_COLOR: 'danger'
  307. SLACK_FOOTER: ''
  308. SLACK_ICON_EMOJI: ':github-actions:'
  309. SLACK_TITLE: 'Docker Debug Build failed:'
  310. SLACK_USERNAME: 'GitHub Actions'
  311. SLACK_MESSAGE: |-
  312. ${{ github.repository }}: Failed to build or publish Docker debug images.
  313. Checkout: ${{ steps.checkout.outcome }}
  314. Generate release tags: ${{ steps.release-tags.outcome }}
  315. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  316. Setup environment: ${{ steps.env.outcome }}
  317. Setup QEMU: ${{ steps.qemu.outcome }}
  318. Setup buildx: ${{ steps.buildx.outcome }}
  319. Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
  320. Login to GHCR: ${{ steps.ghcr-login.outcome }}
  321. Login to Quay: ${{ steps.quay-login.outcome }}
  322. Build and publish images: ${{ steps.build.outcome }}
  323. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  324. if: >-
  325. ${{
  326. failure()
  327. && github.event_name != 'pull_request'
  328. && startsWith(github.ref, 'refs/heads/master')
  329. && github.repository == 'netdata/netdata'
  330. }}