docker.yml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. ---
  2. # Handle building docker images both for CI checks and for eleases.
  3. #
  4. # The case of releaases is unfortunately rather complicated, as Docker
  5. # tooling does not have great support for handling of multiarch images
  6. # published to multiple registries. As a result, we have to build the
  7. # images, export the cache, and then _rebuild_ the images using the exported
  8. # cache but with different output parameters for buildx. We also need to
  9. # do the second build step as a separate job for each registry so that a
  10. # failure to publish one place won’t break publishing elsewhere.
  11. name: Docker
  12. on:
  13. push:
  14. branches:
  15. - master
  16. pull_request: null
  17. workflow_dispatch:
  18. inputs:
  19. version:
  20. description: Version Tag
  21. default: nightly
  22. required: true
  23. env:
  24. DISABLE_TELEMETRY: 1
  25. concurrency:
  26. group: docker-${{ github.ref }}-${{ github.event_name }}
  27. cancel-in-progress: true
  28. jobs:
  29. file-check: # Check what files changed if we’re being run in a PR or on a push.
  30. name: Check Modified Files
  31. runs-on: ubuntu-latest
  32. outputs:
  33. run: ${{ steps.check-run.outputs.run }}
  34. skip-go: ${{ steps.check-go.outputs.skip-go }}
  35. steps:
  36. - name: Checkout
  37. id: checkout
  38. if: github.event_name != 'workflow_dispatch'
  39. uses: actions/checkout@v4
  40. with:
  41. fetch-depth: 0
  42. submodules: recursive
  43. - name: Check source files
  44. id: check-source-files
  45. if: github.event_name != 'workflow_dispatch'
  46. uses: tj-actions/changed-files@v45
  47. with:
  48. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  49. files: |
  50. **/*.c
  51. **/*.cc
  52. **/*.h
  53. **/*.hh
  54. **/*.in
  55. **/*.patch
  56. src/aclk/aclk-schemas/
  57. src/ml/dlib/
  58. src/fluent-bit/
  59. src/web/server/h2o/libh2o/
  60. files_ignore: |
  61. netdata.spec.in
  62. **/*.md
  63. - name: Check build system files
  64. id: check-build-files
  65. if: github.event_name != 'workflow_dispatch'
  66. uses: tj-actions/changed-files@v45
  67. with:
  68. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  69. files: |
  70. .dockerignore
  71. CMakeLists.txt
  72. netdata-installer.sh
  73. .github/workflows/docker.yml
  74. .github/scripts/docker-test.sh
  75. .github/scripts/gen-docker-tags.py
  76. .github/scripts/gen-docker-imagetool-args.py
  77. packaging/cmake/
  78. packaging/docker/
  79. packaging/installer/
  80. packaging/runtime-check.sh
  81. packaging/*.version
  82. packaging/*.checksums
  83. files_ignore: |
  84. **/*.md
  85. packaging/repoconfig/
  86. - name: List all changed files in pattern
  87. continue-on-error: true
  88. if: github.event_name != 'workflow_dispatch'
  89. env:
  90. CHANGED_SOURCE_FILES: ${{ steps.check-source-files.outputs.all_changed_files }}
  91. CHANGED_BUILD_FILES: ${{ steps.check-build-files.outputs.all_changed_files }}
  92. run: |
  93. for file in ${CHANGED_SOURCE_FILES} ${CHANGED_BUILD_FILES} ; do
  94. echo "$file was changed"
  95. done
  96. - name: Check Run
  97. id: check-run
  98. run: |
  99. if [ "${{ steps.check-source-files.outputs.any_modified }}" == "true" ] || [ "${{ steps.check-build-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  100. echo 'run=true' >> "${GITHUB_OUTPUT}"
  101. else
  102. echo 'run=false' >> "${GITHUB_OUTPUT}"
  103. fi
  104. - name: Check Go
  105. id: check-go
  106. env:
  107. OTHER_CHANGED_FILES: ${{ steps.check-source-files.outputs.other_changed_files }}
  108. run: |
  109. if [ '${{ github.event_name }}' == 'pull_request' ]; then
  110. if echo "${OTHER_CHANGED_FILES}" | grep -q '.*/(.*\.go|go\.mod|go\.sum)$' || [ "${{ steps.check-build-files.outputs.any_modified }}" == "true" ]; then
  111. echo 'skip-go=' >> "${GITHUB_OUTPUT}"
  112. else
  113. echo 'skip-go=--disable-go' >> "${GITHUB_OUTPUT}"
  114. fi
  115. else
  116. echo 'skip-go=' >> "${GITHUB_OUTPUT}"
  117. fi
  118. build-images:
  119. name: Build Docker Images
  120. needs:
  121. - file-check
  122. runs-on: ubuntu-latest
  123. strategy:
  124. matrix:
  125. platform:
  126. - linux/amd64
  127. - linux/i386
  128. - linux/arm/v7
  129. - linux/arm64
  130. - linux/ppc64le
  131. # Fail fast on releases, but run everything to completion on other triggers.
  132. fail-fast: ${{ github.event_name == 'workflow_dispatch' }}
  133. steps:
  134. - name: Skip Check
  135. id: skip
  136. if: needs.file-check.outputs.run != 'true'
  137. run: echo "SKIPPED"
  138. - name: Checkout
  139. id: checkout
  140. if: needs.file-check.outputs.run == 'true'
  141. uses: actions/checkout@v4
  142. with:
  143. fetch-depth: 0
  144. submodules: recursive
  145. - name: Generate Artifact Name
  146. id: artifact-name
  147. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  148. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  149. - name: Mark image as official
  150. id: env
  151. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  152. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  153. - name: Setup QEMU
  154. id: qemu
  155. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64' && needs.file-check.outputs.run == 'true'
  156. uses: docker/setup-qemu-action@v3
  157. - name: Setup Buildx
  158. id: prepare
  159. if: needs.file-check.outputs.run == 'true'
  160. uses: docker/setup-buildx-action@v3
  161. - name: Build Image
  162. id: build
  163. if: needs.file-check.outputs.run == 'true'
  164. uses: docker/build-push-action@v6
  165. with:
  166. platforms: ${{ matrix.platform }}
  167. tags: netdata/netdata:test
  168. load: true
  169. cache-to: type=local,dest=/tmp/build-cache,mode=max
  170. build-args: |
  171. OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  172. EXTRA_INSTALL_OPTS=${{ needs.file-check.outputs.skip-go }}
  173. - name: Test Image
  174. id: test
  175. if: needs.file-check.outputs.run == 'true' && matrix.platform == 'linux/amd64'
  176. run: .github/scripts/docker-test.sh
  177. - name: Upload Cache
  178. id: upload-cache
  179. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  180. uses: actions/upload-artifact@v4.4.2
  181. with:
  182. name: cache-${{ steps.artifact-name.outputs.platform }}
  183. path: /tmp/build-cache/*
  184. retention-days: 1
  185. - name: Failure Notification
  186. uses: rtCamp/action-slack-notify@v2
  187. env:
  188. SLACK_COLOR: 'danger'
  189. SLACK_FOOTER: ''
  190. SLACK_ICON_EMOJI: ':github-actions:'
  191. SLACK_TITLE: 'Docker build failed:'
  192. SLACK_USERNAME: 'GitHub Actions'
  193. SLACK_MESSAGE: |-
  194. ${{ github.repository }}: Building or testing Docker image for ${{ matrix.platform }} failed.
  195. Checkout: ${{ steps.checkout.outcome }}
  196. Determine artifact name: ${{ steps.artifact-name.outcome }}
  197. Setup environment: ${{ steps.env.outcome }}
  198. Setup QEMU: ${{ steps.qemu.outcome }}
  199. Setup buildx: ${{ steps.prepare.outcome }}
  200. Build image: ${{ steps.build.outcome }}
  201. Test image: ${{ steps.test.outcome }}
  202. Upload build cache: ${{ steps.upload-cache.outcome }}
  203. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  204. if: >-
  205. ${{
  206. failure()
  207. && github.event_name != 'pull_request'
  208. && github.repository == 'netdata/netdata'
  209. && needs.file-check.outputs.run == 'true'
  210. }}
  211. gen-tags:
  212. name: Generate Docker Tags
  213. runs-on: ubuntu-latest
  214. if: github.event_name == 'workflow_dispatch'
  215. outputs:
  216. tags: ${{ steps.tag.outputs.tags }}
  217. steps:
  218. - name: Checkout
  219. id: checkout
  220. uses: actions/checkout@v4
  221. - name: Generate Tags
  222. id: tag
  223. run: |
  224. if [ ${{ github.event_name }} = 'workflow_dispatch' ]; then
  225. echo "tags=$(.github/scripts/gen-docker-tags.py ${{ github.event_name }} ${{ github.event.inputs.version }})" >> "${GITHUB_OUTPUT}"
  226. else
  227. echo "tags=$(.github/scripts/gen-docker-tags.py ${{ github.event_name }} '')" >> "${GITHUB_OUTPUT}"
  228. fi
  229. build-images-docker-hub:
  230. name: Push Images to Docker Hub
  231. if: github.event_name == 'workflow_dispatch'
  232. needs:
  233. - build-images
  234. - gen-tags
  235. strategy:
  236. matrix:
  237. platform:
  238. - linux/amd64
  239. - linux/i386
  240. - linux/arm/v7
  241. - linux/arm64
  242. - linux/ppc64le
  243. runs-on: ubuntu-latest
  244. steps:
  245. - name: Checkout
  246. id: checkout
  247. uses: actions/checkout@v4
  248. with:
  249. fetch-depth: 0
  250. submodules: recursive
  251. - name: Generate Artifact Name
  252. id: artifact-name
  253. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  254. - name: Download Cache
  255. id: fetch-cache
  256. uses: actions/download-artifact@v4
  257. with:
  258. name: cache-${{ steps.artifact-name.outputs.platform }}
  259. path: /tmp/build-cache
  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. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  267. uses: docker/setup-qemu-action@v3
  268. - name: Setup Buildx
  269. id: prepare
  270. uses: docker/setup-buildx-action@v3
  271. - name: Registry Login
  272. id: login
  273. if: github.repository == 'netdata/netdata'
  274. uses: docker/login-action@v3
  275. with:
  276. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  277. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  278. - name: Build Image
  279. id: build
  280. uses: docker/build-push-action@v6
  281. with:
  282. platforms: ${{ matrix.platform }}
  283. cache-from: type=local,src=/tmp/build-cache
  284. outputs: type=image,name=netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  285. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  286. - name: Export Digest
  287. id: export-digest
  288. if: github.repository == 'netdata/netdata'
  289. run: |
  290. mkdir -p /tmp/digests
  291. digest="${{ steps.build.outputs.digest }}"
  292. touch "/tmp/digests/${digest#sha256:}"
  293. - name: Upload digest
  294. id: upload-digest
  295. if: github.repository == 'netdata/netdata'
  296. uses: actions/upload-artifact@v4.4.2
  297. with:
  298. name: docker-digests-${{ steps.artifact-name.outputs.platform }}
  299. path: /tmp/digests/*
  300. if-no-files-found: error
  301. retention-days: 1
  302. - name: Failure Notification
  303. uses: rtCamp/action-slack-notify@v2
  304. env:
  305. SLACK_COLOR: 'danger'
  306. SLACK_FOOTER: ''
  307. SLACK_ICON_EMOJI: ':github-actions:'
  308. SLACK_TITLE: 'Docker Hub upload failed:'
  309. SLACK_USERNAME: 'GitHub Actions'
  310. SLACK_MESSAGE: |-
  311. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on Docker Hub failed.
  312. Checkout: ${{ steps.checkout.outcome }}
  313. Determine artifact name: ${{ steps.artifact-name.outcome }}
  314. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  315. Setup environment: ${{ steps.env.outcome }}
  316. Setup QEMU: ${{ steps.qemu.outcome }}
  317. Setup buildx: ${{ steps.prepare.outcome }}
  318. Login to registry: ${{ steps.login.outcome }}
  319. Build image: ${{ steps.build.outcome }}
  320. Export digest: ${{ steps.export-digest.outcome }}
  321. Upload digest: ${{ steps.upload-digest.outcome }}
  322. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  323. if: >-
  324. ${{
  325. failure()
  326. && github.repository == 'netdata/netdata'
  327. }}
  328. publish-docker-hub:
  329. name: Consolidate and tag images for DockerHub
  330. if: github.event_name == 'workflow_dispatch'
  331. needs:
  332. - build-images-docker-hub
  333. - gen-tags
  334. runs-on: ubuntu-latest
  335. steps:
  336. - name: Checkout
  337. id: checkout
  338. uses: actions/checkout@v4
  339. - name: Download digests
  340. id: fetch-digests
  341. uses: actions/download-artifact@v4
  342. with:
  343. path: /tmp/digests
  344. pattern: docker-digests-*
  345. merge-multiple: true
  346. - name: Setup Buildx
  347. id: prepare
  348. uses: docker/setup-buildx-action@v3
  349. - name: Registry Login
  350. id: login
  351. if: github.repository == 'netdata/netdata'
  352. uses: docker/login-action@v3
  353. with:
  354. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  355. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  356. - name: Create and Push Manifest
  357. id: manifest
  358. if: github.repository == 'netdata/netdata'
  359. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests '' "${{ needs.gen-tags.outputs.tags }}")
  360. - name: Failure Notification
  361. uses: rtCamp/action-slack-notify@v2
  362. env:
  363. SLACK_COLOR: 'danger'
  364. SLACK_FOOTER: ''
  365. SLACK_ICON_EMOJI: ':github-actions:'
  366. SLACK_TITLE: 'Publishing Docker images to Docker Hub failed:'
  367. SLACK_USERNAME: 'GitHub Actions'
  368. SLACK_MESSAGE: |-
  369. ${{ github.repository }}: Publishing Docker images to Docker Hub failed.
  370. Checkout: ${{ steps.checkout.outcome }}
  371. Download digests: ${{ steps.fetch-digests.outcome }}
  372. Setup buildx: ${{ steps.prepare.outcome }}
  373. Login to registry: ${{ steps.login.outcome }}
  374. Create and push manifest: ${{ steps.manifest.outcome }}
  375. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  376. if: >-
  377. ${{
  378. failure()
  379. && github.repository == 'netdata/netdata'
  380. }}
  381. build-images-quay:
  382. name: Push Images to Quay.io
  383. if: github.event_name == 'workflow_dispatch'
  384. needs:
  385. - build-images
  386. - gen-tags
  387. strategy:
  388. matrix:
  389. platform:
  390. - linux/amd64
  391. - linux/i386
  392. - linux/arm/v7
  393. - linux/arm64
  394. - linux/ppc64le
  395. runs-on: ubuntu-latest
  396. steps:
  397. - name: Checkout
  398. id: checkout
  399. uses: actions/checkout@v4
  400. with:
  401. fetch-depth: 0
  402. submodules: recursive
  403. - name: Generate Artifact Name
  404. id: artifact-name
  405. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  406. - name: Download Cache
  407. id: fetch-cache
  408. uses: actions/download-artifact@v4
  409. with:
  410. name: cache-${{ steps.artifact-name.outputs.platform }}
  411. path: /tmp/build-cache
  412. - name: Mark image as official
  413. id: env
  414. if: github.repository == 'netdata/netdata'
  415. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  416. - name: Setup QEMU
  417. id: qemu
  418. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  419. uses: docker/setup-qemu-action@v3
  420. - name: Setup Buildx
  421. id: prepare
  422. uses: docker/setup-buildx-action@v3
  423. - name: Registry Login
  424. id: login
  425. if: github.repository == 'netdata/netdata'
  426. uses: docker/login-action@v3
  427. with:
  428. registry: quay.io
  429. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  430. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  431. - name: Build Image
  432. id: build
  433. uses: docker/build-push-action@v6
  434. with:
  435. platforms: ${{ matrix.platform }}
  436. cache-from: type=local,src=/tmp/build-cache
  437. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  438. outputs: type=image,name=quay.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  439. - name: Export Digest
  440. id: export-digest
  441. if: github.repository == 'netdata/netdata'
  442. run: |
  443. mkdir -p /tmp/digests
  444. digest="${{ steps.build.outputs.digest }}"
  445. touch "/tmp/digests/${digest#sha256:}"
  446. - name: Upload digest
  447. id: upload-digest
  448. if: github.repository == 'netdata/netdata'
  449. uses: actions/upload-artifact@v4.4.2
  450. with:
  451. name: quay-digests-${{ steps.artifact-name.outputs.platform }}
  452. path: /tmp/digests/*
  453. if-no-files-found: error
  454. retention-days: 1
  455. - name: Failure Notification
  456. uses: rtCamp/action-slack-notify@v2
  457. env:
  458. SLACK_COLOR: 'danger'
  459. SLACK_FOOTER: ''
  460. SLACK_ICON_EMOJI: ':github-actions:'
  461. SLACK_TITLE: 'Quay.io upload failed:'
  462. SLACK_USERNAME: 'GitHub Actions'
  463. SLACK_MESSAGE: |-
  464. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on Quay.io failed.
  465. Checkout: ${{ steps.checkout.outcome }}
  466. Determine artifact name: ${{ steps.artifact-name.outcome }}
  467. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  468. Setup environment: ${{ steps.env.outcome }}
  469. Setup QEMU: ${{ steps.qemu.outcome }}
  470. Setup buildx: ${{ steps.prepare.outcome }}
  471. Login to registry: ${{ steps.login.outcome }}
  472. Build image: ${{ steps.build.outcome }}
  473. Export digest: ${{ steps.export-digest.outcome }}
  474. Upload digest: ${{ steps.upload-digest.outcome }}
  475. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  476. if: >-
  477. ${{
  478. failure()
  479. && github.repository == 'netdata/netdata'
  480. }}
  481. publish-quay:
  482. name: Consolidate and tag images for Quay.io
  483. if: github.event_name == 'workflow_dispatch'
  484. needs:
  485. - build-images-quay
  486. - gen-tags
  487. runs-on: ubuntu-latest
  488. steps:
  489. - name: Checkout
  490. id: checkout
  491. uses: actions/checkout@v4
  492. - name: Download digests
  493. id: fetch-digests
  494. uses: actions/download-artifact@v4
  495. with:
  496. path: /tmp/digests
  497. pattern: quay-digests-*
  498. merge-multiple: true
  499. - name: Setup Buildx
  500. id: prepare
  501. uses: docker/setup-buildx-action@v3
  502. - name: Registry Login
  503. id: login
  504. if: github.repository == 'netdata/netdata'
  505. uses: docker/login-action@v3
  506. with:
  507. registry: quay.io
  508. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  509. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  510. - name: Create and Push Manifest
  511. id: manifest
  512. if: github.repository == 'netdata/netdata'
  513. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'quay.io' "${{ needs.gen-tags.outputs.tags }}")
  514. - name: Failure Notification
  515. uses: rtCamp/action-slack-notify@v2
  516. env:
  517. SLACK_COLOR: 'danger'
  518. SLACK_FOOTER: ''
  519. SLACK_ICON_EMOJI: ':github-actions:'
  520. SLACK_TITLE: 'Publishing Docker images on Quay.io failed:'
  521. SLACK_USERNAME: 'GitHub Actions'
  522. SLACK_MESSAGE: |-
  523. ${{ github.repository }}: Publishing Docker images on Quay.io failed.
  524. Checkout: ${{ steps.checkout.outcome }}
  525. Download digests: ${{ steps.fetch-digests.outcome }}
  526. Setup buildx: ${{ steps.prepare.outcome }}
  527. Login to registry: ${{ steps.login.outcome }}
  528. Create and push manifest: ${{ steps.manifest.outcome }}
  529. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  530. if: >-
  531. ${{
  532. failure()
  533. && github.repository == 'netdata/netdata'
  534. }}
  535. build-images-ghcr:
  536. name: Push Images to GHCR
  537. if: github.event_name == 'workflow_dispatch'
  538. needs:
  539. - build-images
  540. - gen-tags
  541. strategy:
  542. matrix:
  543. platform:
  544. - linux/amd64
  545. - linux/i386
  546. - linux/arm/v7
  547. - linux/arm64
  548. - linux/ppc64le
  549. runs-on: ubuntu-latest
  550. steps:
  551. - name: Checkout
  552. id: checkout
  553. uses: actions/checkout@v4
  554. with:
  555. fetch-depth: 0
  556. submodules: recursive
  557. - name: Generate Artifact Name
  558. id: artifact-name
  559. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  560. - name: Download Cache
  561. id: fetch-cache
  562. uses: actions/download-artifact@v4
  563. with:
  564. name: cache-${{ steps.artifact-name.outputs.platform }}
  565. path: /tmp/build-cache
  566. - name: Mark image as official
  567. id: env
  568. if: github.repository == 'netdata/netdata'
  569. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  570. - name: Setup QEMU
  571. id: qemu
  572. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  573. uses: docker/setup-qemu-action@v3
  574. - name: Setup Buildx
  575. id: prepare
  576. uses: docker/setup-buildx-action@v3
  577. - name: Registry Login
  578. id: login
  579. if: github.repository == 'netdata/netdata'
  580. uses: docker/login-action@v3
  581. with:
  582. registry: ghcr.io
  583. username: ${{ github.repository_owner }}
  584. password: ${{ secrets.GITHUB_TOKEN }}
  585. - name: Build Image
  586. id: build
  587. uses: docker/build-push-action@v6
  588. with:
  589. platforms: ${{ matrix.platform }}
  590. cache-from: type=local,src=/tmp/build-cache
  591. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  592. outputs: type=image,name=ghcr.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  593. - name: Export Digest
  594. id: export-digest
  595. if: github.repository == 'netdata/netdata'
  596. run: |
  597. mkdir -p /tmp/digests
  598. digest="${{ steps.build.outputs.digest }}"
  599. touch "/tmp/digests/${digest#sha256:}"
  600. - name: Upload digest
  601. id: upload-digest
  602. if: github.repository == 'netdata/netdata'
  603. uses: actions/upload-artifact@v4.4.2
  604. with:
  605. name: ghcr-digests-${{ steps.artifact-name.outputs.platform }}
  606. path: /tmp/digests/*
  607. if-no-files-found: error
  608. retention-days: 1
  609. - name: Failure Notification
  610. uses: rtCamp/action-slack-notify@v2
  611. env:
  612. SLACK_COLOR: 'danger'
  613. SLACK_FOOTER: ''
  614. SLACK_ICON_EMOJI: ':github-actions:'
  615. SLACK_TITLE: 'GHCR upload failed:'
  616. SLACK_USERNAME: 'GitHub Actions'
  617. SLACK_MESSAGE: |-
  618. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on GHCR failed.
  619. Checkout: ${{ steps.checkout.outcome }}
  620. Determine artifact name: ${{ steps.artifact-name.outcome }}
  621. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  622. Setup environment: ${{ steps.env.outcome }}
  623. Setup QEMU: ${{ steps.qemu.outcome }}
  624. Setup buildx: ${{ steps.prepare.outcome }}
  625. Login to registry: ${{ steps.login.outcome }}
  626. Build image: ${{ steps.build.outcome }}
  627. Export digest: ${{ steps.export-digest.outcome }}
  628. Upload digest: ${{ steps.upload-digest.outcome }}
  629. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  630. if: >-
  631. ${{
  632. failure()
  633. && github.repository == 'netdata/netdata'
  634. }}
  635. publish-ghcr:
  636. name: Consolidate and tag images for GHCR
  637. if: github.event_name == 'workflow_dispatch'
  638. needs:
  639. - build-images-ghcr
  640. - gen-tags
  641. runs-on: ubuntu-latest
  642. steps:
  643. - name: Checkout
  644. id: checkout
  645. uses: actions/checkout@v4
  646. - name: Download digests
  647. id: fetch-digests
  648. uses: actions/download-artifact@v4
  649. with:
  650. path: /tmp/digests
  651. pattern: ghcr-digests-*
  652. merge-multiple: true
  653. - name: Setup Buildx
  654. id: prepare
  655. uses: docker/setup-buildx-action@v3
  656. - name: Registry Login
  657. id: login
  658. if: github.repository == 'netdata/netdata'
  659. uses: docker/login-action@v3
  660. with:
  661. registry: ghcr.io
  662. username: ${{ github.repository_owner }}
  663. password: ${{ secrets.GITHUB_TOKEN }}
  664. - name: Create and Push Manifest
  665. id: manifest
  666. if: github.repository == 'netdata/netdata'
  667. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'ghcr.io' "${{ needs.gen-tags.outputs.tags }}")
  668. - name: Failure Notification
  669. uses: rtCamp/action-slack-notify@v2
  670. env:
  671. SLACK_COLOR: 'danger'
  672. SLACK_FOOTER: ''
  673. SLACK_ICON_EMOJI: ':github-actions:'
  674. SLACK_TITLE: 'Publishing Docker images on GHCR failed:'
  675. SLACK_USERNAME: 'GitHub Actions'
  676. SLACK_MESSAGE: |-
  677. ${{ github.repository }}: Publishing Docker images on GHCR failed.
  678. Checkout: ${{ steps.checkout.outcome }}
  679. Download digests: ${{ steps.fetch-digests.outcome }}
  680. Setup buildx: ${{ steps.prepare.outcome }}
  681. Login to registry: ${{ steps.login.outcome }}
  682. Create and push manifest: ${{ steps.manifest.outcome }}
  683. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  684. if: >-
  685. ${{
  686. failure()
  687. && github.repository == 'netdata/netdata'
  688. }}
  689. trigger-subsequent-workflows:
  690. if: github.event_name == 'workflow_dispatch'
  691. name: Trigger subsquent workflows for newly added versions
  692. needs:
  693. - publish-docker-hub
  694. - gen-tags
  695. runs-on: ubuntu-latest
  696. steps:
  697. - name: Checkout
  698. id: checkout
  699. uses: actions/checkout@v4
  700. with:
  701. submodules: recursive
  702. - name: Trigger Helmchart PR
  703. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  704. id: trigger-helmchart
  705. uses: benc-uk/workflow-dispatch@v1
  706. with:
  707. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  708. repo: netdata/helmchart
  709. workflow: Agent Version PR
  710. ref: refs/heads/master
  711. inputs: '{"agent_version": "v${{ inputs.version }}"}'
  712. - name: Trigger MSI build
  713. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  714. id: trigger-msi
  715. uses: benc-uk/workflow-dispatch@v1
  716. with:
  717. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  718. repo: netdata/msi-installer
  719. workflow: Build
  720. ref: refs/heads/master
  721. inputs: '{"tag": "stable", "pwd": "${{ secrets.MSI_CODE_SIGNING_PASSWORD }}"}'
  722. - name: Failure Notification
  723. uses: rtCamp/action-slack-notify@v2
  724. env:
  725. SLACK_COLOR: 'danger'
  726. SLACK_FOOTER: ''
  727. SLACK_ICON_EMOJI: ':github-actions:'
  728. SLACK_TITLE: ':'
  729. SLACK_USERNAME: 'GitHub Actions'
  730. SLACK_MESSAGE: |-
  731. ${{ github.repository }}: Version cascade failed
  732. Checkout: ${{ steps.checkout.outcome }}
  733. Trigger Helmchart PR: ${{ steps.trigger-helmchart.outcome }}
  734. Trigger MSI build: ${{ steps.trigger-msi.outcome }}
  735. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  736. if: >-
  737. ${{
  738. failure()
  739. && github.event_name != 'pull_request'
  740. && startsWith(github.ref, 'refs/heads/master')
  741. && github.repository == 'netdata/netdata'
  742. }}