docker.yml 15 KB

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