docker.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. file-check: # Check what files changed if we’re being run in a PR or on a push.
  21. name: Check Modified Files
  22. runs-on: ubuntu-latest
  23. outputs:
  24. run: ${{ steps.check-run.outputs.run }}
  25. steps:
  26. - name: Checkout
  27. id: checkout
  28. uses: actions/checkout@v4
  29. with:
  30. fetch-depth: 0
  31. submodules: recursive
  32. - name: Check files
  33. id: file-check
  34. uses: tj-actions/changed-files@v41
  35. with:
  36. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  37. files: |
  38. **.c
  39. **.cc
  40. **.h
  41. **.hh
  42. **.in
  43. .dockerignore
  44. netdata-installer.sh
  45. CMakeLists.txt
  46. .github/workflows/docker.yml
  47. .github/scripts/docker-test.sh
  48. build/**
  49. packaging/docker/**
  50. packaging/installer/**
  51. aclk/aclk-schemas/
  52. ml/dlib/
  53. mqtt_websockets
  54. web/server/h2o/libh2o
  55. files_ignore: |
  56. netdata.spec.in
  57. **.md
  58. - name: Check Run
  59. id: check-run
  60. run: |
  61. if [ "${{ steps.file-check.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  62. echo 'run=true' >> "${GITHUB_OUTPUT}"
  63. else
  64. echo 'run=false' >> "${GITHUB_OUTPUT}"
  65. fi
  66. docker-test:
  67. name: Docker Runtime Test
  68. needs:
  69. - file-check
  70. runs-on: ubuntu-latest
  71. steps:
  72. - name: Skip Check
  73. id: skip
  74. if: needs.file-check.outputs.run != 'true'
  75. run: echo "SKIPPED"
  76. - name: Checkout
  77. id: checkout
  78. if: needs.file-check.outputs.run == 'true'
  79. uses: actions/checkout@v4
  80. with:
  81. submodules: recursive
  82. - name: Setup Buildx
  83. id: prepare
  84. if: needs.file-check.outputs.run == 'true'
  85. uses: docker/setup-buildx-action@v3
  86. - name: Test Build
  87. id: build
  88. if: needs.file-check.outputs.run == 'true'
  89. uses: docker/build-push-action@v5
  90. with:
  91. load: true
  92. push: false
  93. tags: netdata/netdata:test
  94. - name: Test Image
  95. id: test
  96. if: needs.file-check.outputs.run == 'true'
  97. run: .github/scripts/docker-test.sh
  98. - name: Failure Notification
  99. uses: rtCamp/action-slack-notify@v2
  100. env:
  101. SLACK_COLOR: 'danger'
  102. SLACK_FOOTER: ''
  103. SLACK_ICON_EMOJI: ':github-actions:'
  104. SLACK_TITLE: 'Docker runtime testing failed:'
  105. SLACK_USERNAME: 'GitHub Actions'
  106. SLACK_MESSAGE: |-
  107. ${{ github.repository }}: Building or testing Docker image for linux/amd64 failed.
  108. CHeckout: ${{ steps.checkout.outcome }}
  109. Setup buildx: ${{ steps.prepare.outcome }}
  110. Build image: ${{ steps.build.outcome }}
  111. Test image: ${{ steps.test.outcome }}
  112. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  113. if: >-
  114. ${{
  115. failure()
  116. && github.event_name != 'pull_request'
  117. && startsWith(github.ref, 'refs/heads/master')
  118. && github.repository == 'netdata/netdata'
  119. && needs.file-check.outputs.run == 'true'
  120. }}
  121. docker-ci:
  122. if: github.event_name != 'workflow_dispatch'
  123. name: Docker Alt Arch Builds
  124. needs:
  125. - docker-test
  126. - file-check
  127. runs-on: ubuntu-latest
  128. strategy:
  129. matrix:
  130. platforms:
  131. - linux/i386
  132. - linux/arm/v7
  133. - linux/arm64
  134. - linux/ppc64le
  135. steps:
  136. - name: Skip Check
  137. id: skip
  138. if: needs.file-check.outputs.run != 'true'
  139. run: echo "SKIPPED"
  140. - name: Checkout
  141. id: checkout
  142. if: needs.file-check.outputs.run == 'true'
  143. uses: actions/checkout@v4
  144. with:
  145. submodules: recursive
  146. - name: Setup QEMU
  147. id: qemu
  148. if: matrix.platforms != 'linux/i386' && needs.file-check.outputs.run == 'true'
  149. uses: docker/setup-qemu-action@v3
  150. - name: Setup Buildx
  151. id: buildx
  152. if: needs.file-check.outputs.run == 'true'
  153. uses: docker/setup-buildx-action@v3
  154. - name: Build
  155. id: build
  156. if: needs.file-check.outputs.run == 'true'
  157. uses: docker/build-push-action@v5
  158. with:
  159. platforms: ${{ matrix.platforms }}
  160. load: false
  161. push: false
  162. tags: netdata/netdata:test
  163. - name: Failure Notification
  164. uses: rtCamp/action-slack-notify@v2
  165. env:
  166. SLACK_COLOR: 'danger'
  167. SLACK_FOOTER: ''
  168. SLACK_ICON_EMOJI: ':github-actions:'
  169. SLACK_TITLE: 'Docker build testing failed:'
  170. SLACK_USERNAME: 'GitHub Actions'
  171. SLACK_MESSAGE: |-
  172. ${{ github.repository }}: Building Docker image for ${{ matrix.platforms }} failed.
  173. CHeckout: ${{ steps.checkout.outcome }}
  174. Setup QEMU: ${{ steps.qemu.outcome }}
  175. Setup buildx: ${{ steps.buildx.outcome }}
  176. Build image: ${{ steps.build.outcome }}
  177. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  178. if: >-
  179. ${{
  180. failure()
  181. && github.event_name != 'pull_request'
  182. && startsWith(github.ref, 'refs/heads/master')
  183. && github.repository == 'netdata/netdata'
  184. && needs.file-check.outputs.run == 'true'
  185. }}
  186. normalize-tag: # Fix the release tag if needed
  187. name: Normalize Release Tag
  188. runs-on: ubuntu-latest
  189. if: github.event_name == 'workflow_dispatch'
  190. outputs:
  191. tag: ${{ steps.tag.outputs.tag }}
  192. steps:
  193. - name: Normalize Tag
  194. id: tag
  195. run: |
  196. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  197. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  198. else
  199. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  200. fi
  201. docker-publish:
  202. if: github.event_name == 'workflow_dispatch'
  203. name: Docker Build and Publish
  204. needs:
  205. - docker-test
  206. - normalize-tag
  207. runs-on: ubuntu-latest
  208. steps:
  209. - name: Checkout
  210. id: checkout
  211. uses: actions/checkout@v4
  212. with:
  213. submodules: recursive
  214. - name: Determine which tags to use
  215. id: release-tags
  216. if: github.event.inputs.version != 'nightly'
  217. run: |
  218. 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 }} '')" \
  219. >> "${GITHUB_ENV}"
  220. - name: Determine which tags to use
  221. id: nightly-tags
  222. if: github.event.inputs.version == 'nightly'
  223. run: |
  224. 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}"
  225. - name: Mark image as official
  226. id: env
  227. if: github.repository == 'netdata/netdata'
  228. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  229. - name: Setup QEMU
  230. id: qemu
  231. uses: docker/setup-qemu-action@v3
  232. - name: Setup Buildx
  233. id: buildx
  234. uses: docker/setup-buildx-action@v3
  235. - name: Docker Hub Login
  236. id: docker-hub-login
  237. if: github.repository == 'netdata/netdata'
  238. uses: docker/login-action@v3
  239. with:
  240. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  241. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  242. - name: GitHub Container Registry Login
  243. id: ghcr-login
  244. if: github.repository == 'netdata/netdata'
  245. uses: docker/login-action@v3
  246. with:
  247. registry: ghcr.io
  248. username: ${{ github.repository_owner }}
  249. password: ${{ secrets.GITHUB_TOKEN }}
  250. - name: Quay.io Login
  251. id: quay-login
  252. if: github.repository == 'netdata/netdata'
  253. uses: docker/login-action@v3
  254. with:
  255. registry: quay.io
  256. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  257. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  258. - name: Docker Build
  259. id: build
  260. uses: docker/build-push-action@v5
  261. with:
  262. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  263. push: ${{ github.repository == 'netdata/netdata' }}
  264. tags: ${{ env.tags }}
  265. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  266. - name: Failure Notification
  267. uses: rtCamp/action-slack-notify@v2
  268. env:
  269. SLACK_COLOR: 'danger'
  270. SLACK_FOOTER: ''
  271. SLACK_ICON_EMOJI: ':github-actions:'
  272. SLACK_TITLE: 'Docker Build failed:'
  273. SLACK_USERNAME: 'GitHub Actions'
  274. SLACK_MESSAGE: |-
  275. ${{ github.repository }}: Failed to build or publish Docker images.
  276. CHeckout: ${{ steps.checkout.outcome }}
  277. Generate release tags: ${{ steps.release-tags.outcome }}
  278. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  279. Setup environment: ${{ steps.env.outcome }}
  280. Setup QEMU: ${{ steps.qemu.outcome }}
  281. Setup buildx: ${{ steps.buildx.outcome }}
  282. Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
  283. Login to GHCR: ${{ steps.ghcr-login.outcome }}
  284. Login to Quay: ${{ steps.quay-login.outcome }}
  285. Build and publish images: ${{ steps.build.outcome }}
  286. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  287. if: >-
  288. ${{
  289. failure()
  290. && github.event_name != 'pull_request'
  291. && startsWith(github.ref, 'refs/heads/master')
  292. && github.repository == 'netdata/netdata'
  293. }}
  294. - name: Trigger Helmchart PR
  295. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  296. uses: benc-uk/workflow-dispatch@v1
  297. with:
  298. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  299. repo: netdata/helmchart
  300. workflow: Agent Version PR
  301. ref: refs/heads/master
  302. inputs: '{"agent_version": "${{ needs.normalize-tag.outputs.tag }}"}'
  303. - name: Trigger MSI build
  304. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  305. uses: benc-uk/workflow-dispatch@v1
  306. with:
  307. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  308. repo: netdata/msi-installer
  309. workflow: Build
  310. ref: refs/heads/master
  311. inputs: '{"tag": "${{ needs.normalize-tag.outputs.tag }}", "pwd": "${{ secrets.MSI_CODE_SIGNING_PASSWORD }}"}'
  312. docker-dbg-publish:
  313. if: github.event_name == 'workflow_dispatch'
  314. name: Docker Build and Publish (Debugging Image)
  315. needs:
  316. - docker-test
  317. - normalize-tag
  318. runs-on: ubuntu-latest
  319. steps:
  320. - name: Checkout
  321. id: checkout
  322. uses: actions/checkout@v4
  323. with:
  324. submodules: recursive
  325. - name: Determine which tags to use
  326. id: release-tags
  327. if: github.event.inputs.version != 'nightly'
  328. run: |
  329. 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')" \
  330. >> "${GITHUB_ENV}"
  331. - name: Determine which tags to use
  332. id: nightly-tags
  333. if: github.event.inputs.version == 'nightly'
  334. run: |
  335. 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}"
  336. - name: Mark image as official
  337. id: env
  338. if: github.repository == 'netdata/netdata'
  339. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  340. - name: Setup QEMU
  341. id: qemu
  342. uses: docker/setup-qemu-action@v3
  343. - name: Setup Buildx
  344. id: buildx
  345. uses: docker/setup-buildx-action@v3
  346. - name: Docker Hub Login
  347. id: docker-hub-login
  348. if: github.repository == 'netdata/netdata'
  349. uses: docker/login-action@v3
  350. with:
  351. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  352. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  353. - name: GitHub Container Registry Login
  354. id: ghcr-login
  355. if: github.repository == 'netdata/netdata'
  356. uses: docker/login-action@v3
  357. with:
  358. registry: ghcr.io
  359. username: ${{ github.repository_owner }}
  360. password: ${{ secrets.GITHUB_TOKEN }}
  361. - name: Quay.io Login
  362. id: quay-login
  363. if: github.repository == 'netdata/netdata'
  364. uses: docker/login-action@v3
  365. with:
  366. registry: quay.io
  367. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  368. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  369. - name: Docker Build
  370. id: build
  371. uses: docker/build-push-action@v5
  372. with:
  373. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  374. push: ${{ github.repository == 'netdata/netdata' }}
  375. tags: ${{ env.tags }}
  376. build-args: |
  377. OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  378. DEBUG_BUILD=1
  379. - name: Failure Notification
  380. uses: rtCamp/action-slack-notify@v2
  381. env:
  382. SLACK_COLOR: 'danger'
  383. SLACK_FOOTER: ''
  384. SLACK_ICON_EMOJI: ':github-actions:'
  385. SLACK_TITLE: 'Docker Debug Build failed:'
  386. SLACK_USERNAME: 'GitHub Actions'
  387. SLACK_MESSAGE: |-
  388. ${{ github.repository }}: Failed to build or publish Docker debug images.
  389. Checkout: ${{ steps.checkout.outcome }}
  390. Generate release tags: ${{ steps.release-tags.outcome }}
  391. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  392. Setup environment: ${{ steps.env.outcome }}
  393. Setup QEMU: ${{ steps.qemu.outcome }}
  394. Setup buildx: ${{ steps.buildx.outcome }}
  395. Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
  396. Login to GHCR: ${{ steps.ghcr-login.outcome }}
  397. Login to Quay: ${{ steps.quay-login.outcome }}
  398. Build and publish images: ${{ steps.build.outcome }}
  399. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  400. if: >-
  401. ${{
  402. failure()
  403. && github.event_name != 'pull_request'
  404. && startsWith(github.ref, 'refs/heads/master')
  405. && github.repository == 'netdata/netdata'
  406. }}