docker.yml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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: false
  132. steps:
  133. - name: Skip Check
  134. id: skip
  135. if: needs.file-check.outputs.run != 'true'
  136. run: echo "SKIPPED"
  137. - name: Checkout
  138. id: checkout
  139. if: needs.file-check.outputs.run == 'true'
  140. uses: actions/checkout@v4
  141. with:
  142. fetch-depth: 0
  143. submodules: recursive
  144. - name: Generate Artifact Name
  145. id: artifact-name
  146. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  147. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  148. - name: Mark image as official
  149. id: env
  150. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  151. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  152. - name: Setup QEMU
  153. id: qemu
  154. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64' && needs.file-check.outputs.run == 'true'
  155. run: |
  156. sudo apt-get update
  157. sudo apt-get upgrade -y
  158. sudo apt-get install -y qemu-user-static
  159. - name: Setup Buildx
  160. id: prepare
  161. if: needs.file-check.outputs.run == 'true'
  162. uses: docker/setup-buildx-action@v3
  163. - name: Build Image
  164. id: build
  165. if: needs.file-check.outputs.run == 'true'
  166. uses: docker/build-push-action@v6
  167. with:
  168. platforms: ${{ matrix.platform }}
  169. tags: netdata/netdata:test
  170. load: true
  171. cache-to: type=local,dest=/tmp/build-cache,mode=max
  172. build-args: |
  173. OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  174. EXTRA_INSTALL_OPTS=${{ needs.file-check.outputs.skip-go }}
  175. - name: Test Image
  176. id: test
  177. if: needs.file-check.outputs.run == 'true' && matrix.platform == 'linux/amd64'
  178. run: .github/scripts/docker-test.sh
  179. - name: Upload Cache
  180. id: upload-cache
  181. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  182. uses: actions/upload-artifact@v4.6.0
  183. with:
  184. name: cache-${{ steps.artifact-name.outputs.platform }}
  185. path: /tmp/build-cache/*
  186. retention-days: 1
  187. - name: Failure Notification
  188. uses: rtCamp/action-slack-notify@v2
  189. env:
  190. SLACK_COLOR: 'danger'
  191. SLACK_FOOTER: ''
  192. SLACK_ICON_EMOJI: ':github-actions:'
  193. SLACK_TITLE: 'Docker build failed:'
  194. SLACK_USERNAME: 'GitHub Actions'
  195. SLACK_MESSAGE: |-
  196. ${{ github.repository }}: Building or testing Docker image for ${{ matrix.platform }} failed.
  197. Checkout: ${{ steps.checkout.outcome }}
  198. Determine artifact name: ${{ steps.artifact-name.outcome }}
  199. Setup environment: ${{ steps.env.outcome }}
  200. Setup QEMU: ${{ steps.qemu.outcome }}
  201. Setup buildx: ${{ steps.prepare.outcome }}
  202. Build image: ${{ steps.build.outcome }}
  203. Test image: ${{ steps.test.outcome }}
  204. Upload build cache: ${{ steps.upload-cache.outcome }}
  205. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  206. if: >-
  207. ${{
  208. failure()
  209. && github.event_name != 'pull_request'
  210. && github.repository == 'netdata/netdata'
  211. && needs.file-check.outputs.run == 'true'
  212. }}
  213. gen-tags:
  214. name: Generate Docker Tags
  215. runs-on: ubuntu-latest
  216. if: github.event_name == 'workflow_dispatch'
  217. outputs:
  218. tags: ${{ steps.tag.outputs.tags }}
  219. steps:
  220. - name: Checkout
  221. id: checkout
  222. uses: actions/checkout@v4
  223. - name: Generate Tags
  224. id: tag
  225. run: |
  226. if [ ${{ github.event_name }} = 'workflow_dispatch' ]; then
  227. echo "tags=$(.github/scripts/gen-docker-tags.py ${{ github.event_name }} ${{ github.event.inputs.version }})" >> "${GITHUB_OUTPUT}"
  228. else
  229. echo "tags=$(.github/scripts/gen-docker-tags.py ${{ github.event_name }} '')" >> "${GITHUB_OUTPUT}"
  230. fi
  231. build-images-docker-hub:
  232. name: Push Images to Docker Hub
  233. if: github.event_name == 'workflow_dispatch'
  234. needs:
  235. - build-images
  236. - gen-tags
  237. strategy:
  238. matrix:
  239. platform:
  240. - linux/amd64
  241. - linux/i386
  242. - linux/arm/v7
  243. - linux/arm64
  244. - linux/ppc64le
  245. runs-on: ubuntu-latest
  246. steps:
  247. - name: Checkout
  248. id: checkout
  249. uses: actions/checkout@v4
  250. with:
  251. fetch-depth: 0
  252. submodules: recursive
  253. - name: Generate Artifact Name
  254. id: artifact-name
  255. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  256. - name: Download Cache
  257. id: fetch-cache
  258. uses: actions/download-artifact@v4
  259. with:
  260. name: cache-${{ steps.artifact-name.outputs.platform }}
  261. path: /tmp/build-cache
  262. - name: Mark image as official
  263. id: env
  264. if: github.repository == 'netdata/netdata'
  265. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  266. - name: Setup QEMU
  267. id: qemu
  268. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  269. uses: docker/setup-qemu-action@v3
  270. - name: Setup Buildx
  271. id: prepare
  272. uses: docker/setup-buildx-action@v3
  273. - name: Registry Login
  274. id: login
  275. if: github.repository == 'netdata/netdata'
  276. uses: docker/login-action@v3
  277. with:
  278. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  279. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  280. - name: Build Image
  281. id: build
  282. uses: docker/build-push-action@v6
  283. with:
  284. platforms: ${{ matrix.platform }}
  285. cache-from: type=local,src=/tmp/build-cache
  286. outputs: type=image,name=netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  287. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  288. - name: Export Digest
  289. id: export-digest
  290. if: github.repository == 'netdata/netdata'
  291. run: |
  292. mkdir -p /tmp/digests
  293. digest="${{ steps.build.outputs.digest }}"
  294. touch "/tmp/digests/${digest#sha256:}"
  295. - name: Upload digest
  296. id: upload-digest
  297. if: github.repository == 'netdata/netdata'
  298. uses: actions/upload-artifact@v4.6.0
  299. with:
  300. name: docker-digests-${{ steps.artifact-name.outputs.platform }}
  301. path: /tmp/digests/*
  302. if-no-files-found: error
  303. retention-days: 1
  304. - name: Failure Notification
  305. uses: rtCamp/action-slack-notify@v2
  306. env:
  307. SLACK_COLOR: 'danger'
  308. SLACK_FOOTER: ''
  309. SLACK_ICON_EMOJI: ':github-actions:'
  310. SLACK_TITLE: 'Docker Hub upload failed:'
  311. SLACK_USERNAME: 'GitHub Actions'
  312. SLACK_MESSAGE: |-
  313. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on Docker Hub failed.
  314. Checkout: ${{ steps.checkout.outcome }}
  315. Determine artifact name: ${{ steps.artifact-name.outcome }}
  316. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  317. Setup environment: ${{ steps.env.outcome }}
  318. Setup QEMU: ${{ steps.qemu.outcome }}
  319. Setup buildx: ${{ steps.prepare.outcome }}
  320. Login to registry: ${{ steps.login.outcome }}
  321. Build image: ${{ steps.build.outcome }}
  322. Export digest: ${{ steps.export-digest.outcome }}
  323. Upload digest: ${{ steps.upload-digest.outcome }}
  324. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  325. if: >-
  326. ${{
  327. failure()
  328. && github.repository == 'netdata/netdata'
  329. }}
  330. publish-docker-hub:
  331. name: Consolidate and tag images for DockerHub
  332. if: github.event_name == 'workflow_dispatch'
  333. needs:
  334. - build-images-docker-hub
  335. - gen-tags
  336. runs-on: ubuntu-latest
  337. steps:
  338. - name: Checkout
  339. id: checkout
  340. uses: actions/checkout@v4
  341. - name: Download digests
  342. id: fetch-digests
  343. uses: actions/download-artifact@v4
  344. with:
  345. path: /tmp/digests
  346. pattern: docker-digests-*
  347. merge-multiple: true
  348. - name: Setup Buildx
  349. id: prepare
  350. uses: docker/setup-buildx-action@v3
  351. - name: Registry Login
  352. id: login
  353. if: github.repository == 'netdata/netdata'
  354. uses: docker/login-action@v3
  355. with:
  356. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  357. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  358. - name: Create and Push Manifest
  359. id: manifest
  360. if: github.repository == 'netdata/netdata'
  361. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests '' "${{ needs.gen-tags.outputs.tags }}")
  362. - name: Failure Notification
  363. uses: rtCamp/action-slack-notify@v2
  364. env:
  365. SLACK_COLOR: 'danger'
  366. SLACK_FOOTER: ''
  367. SLACK_ICON_EMOJI: ':github-actions:'
  368. SLACK_TITLE: 'Publishing Docker images to Docker Hub failed:'
  369. SLACK_USERNAME: 'GitHub Actions'
  370. SLACK_MESSAGE: |-
  371. ${{ github.repository }}: Publishing Docker images to Docker Hub failed.
  372. Checkout: ${{ steps.checkout.outcome }}
  373. Download digests: ${{ steps.fetch-digests.outcome }}
  374. Setup buildx: ${{ steps.prepare.outcome }}
  375. Login to registry: ${{ steps.login.outcome }}
  376. Create and push manifest: ${{ steps.manifest.outcome }}
  377. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  378. if: >-
  379. ${{
  380. failure()
  381. && github.repository == 'netdata/netdata'
  382. }}
  383. build-images-quay:
  384. name: Push Images to Quay.io
  385. if: github.event_name == 'workflow_dispatch'
  386. needs:
  387. - build-images
  388. - gen-tags
  389. strategy:
  390. matrix:
  391. platform:
  392. - linux/amd64
  393. - linux/i386
  394. - linux/arm/v7
  395. - linux/arm64
  396. - linux/ppc64le
  397. runs-on: ubuntu-latest
  398. steps:
  399. - name: Checkout
  400. id: checkout
  401. uses: actions/checkout@v4
  402. with:
  403. fetch-depth: 0
  404. submodules: recursive
  405. - name: Generate Artifact Name
  406. id: artifact-name
  407. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  408. - name: Download Cache
  409. id: fetch-cache
  410. uses: actions/download-artifact@v4
  411. with:
  412. name: cache-${{ steps.artifact-name.outputs.platform }}
  413. path: /tmp/build-cache
  414. - name: Mark image as official
  415. id: env
  416. if: github.repository == 'netdata/netdata'
  417. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  418. - name: Setup QEMU
  419. id: qemu
  420. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  421. uses: docker/setup-qemu-action@v3
  422. - name: Setup Buildx
  423. id: prepare
  424. uses: docker/setup-buildx-action@v3
  425. - name: Registry Login
  426. id: login
  427. if: github.repository == 'netdata/netdata'
  428. uses: docker/login-action@v3
  429. with:
  430. registry: quay.io
  431. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  432. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  433. - name: Build Image
  434. id: build
  435. uses: docker/build-push-action@v6
  436. with:
  437. platforms: ${{ matrix.platform }}
  438. cache-from: type=local,src=/tmp/build-cache
  439. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  440. outputs: type=image,name=quay.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  441. - name: Export Digest
  442. id: export-digest
  443. if: github.repository == 'netdata/netdata'
  444. run: |
  445. mkdir -p /tmp/digests
  446. digest="${{ steps.build.outputs.digest }}"
  447. touch "/tmp/digests/${digest#sha256:}"
  448. - name: Upload digest
  449. id: upload-digest
  450. if: github.repository == 'netdata/netdata'
  451. uses: actions/upload-artifact@v4.6.0
  452. with:
  453. name: quay-digests-${{ steps.artifact-name.outputs.platform }}
  454. path: /tmp/digests/*
  455. if-no-files-found: error
  456. retention-days: 1
  457. - name: Failure Notification
  458. uses: rtCamp/action-slack-notify@v2
  459. env:
  460. SLACK_COLOR: 'danger'
  461. SLACK_FOOTER: ''
  462. SLACK_ICON_EMOJI: ':github-actions:'
  463. SLACK_TITLE: 'Quay.io upload failed:'
  464. SLACK_USERNAME: 'GitHub Actions'
  465. SLACK_MESSAGE: |-
  466. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on Quay.io failed.
  467. Checkout: ${{ steps.checkout.outcome }}
  468. Determine artifact name: ${{ steps.artifact-name.outcome }}
  469. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  470. Setup environment: ${{ steps.env.outcome }}
  471. Setup QEMU: ${{ steps.qemu.outcome }}
  472. Setup buildx: ${{ steps.prepare.outcome }}
  473. Login to registry: ${{ steps.login.outcome }}
  474. Build image: ${{ steps.build.outcome }}
  475. Export digest: ${{ steps.export-digest.outcome }}
  476. Upload digest: ${{ steps.upload-digest.outcome }}
  477. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  478. if: >-
  479. ${{
  480. failure()
  481. && github.repository == 'netdata/netdata'
  482. }}
  483. publish-quay:
  484. name: Consolidate and tag images for Quay.io
  485. if: github.event_name == 'workflow_dispatch'
  486. needs:
  487. - build-images-quay
  488. - gen-tags
  489. runs-on: ubuntu-latest
  490. steps:
  491. - name: Checkout
  492. id: checkout
  493. uses: actions/checkout@v4
  494. - name: Download digests
  495. id: fetch-digests
  496. uses: actions/download-artifact@v4
  497. with:
  498. path: /tmp/digests
  499. pattern: quay-digests-*
  500. merge-multiple: true
  501. - name: Setup Buildx
  502. id: prepare
  503. uses: docker/setup-buildx-action@v3
  504. - name: Registry Login
  505. id: login
  506. if: github.repository == 'netdata/netdata'
  507. uses: docker/login-action@v3
  508. with:
  509. registry: quay.io
  510. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  511. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  512. - name: Create and Push Manifest
  513. id: manifest
  514. if: github.repository == 'netdata/netdata'
  515. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'quay.io' "${{ needs.gen-tags.outputs.tags }}")
  516. - name: Failure Notification
  517. uses: rtCamp/action-slack-notify@v2
  518. env:
  519. SLACK_COLOR: 'danger'
  520. SLACK_FOOTER: ''
  521. SLACK_ICON_EMOJI: ':github-actions:'
  522. SLACK_TITLE: 'Publishing Docker images on Quay.io failed:'
  523. SLACK_USERNAME: 'GitHub Actions'
  524. SLACK_MESSAGE: |-
  525. ${{ github.repository }}: Publishing Docker images on Quay.io failed.
  526. Checkout: ${{ steps.checkout.outcome }}
  527. Download digests: ${{ steps.fetch-digests.outcome }}
  528. Setup buildx: ${{ steps.prepare.outcome }}
  529. Login to registry: ${{ steps.login.outcome }}
  530. Create and push manifest: ${{ steps.manifest.outcome }}
  531. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  532. if: >-
  533. ${{
  534. failure()
  535. && github.repository == 'netdata/netdata'
  536. }}
  537. build-images-ghcr:
  538. name: Push Images to GHCR
  539. if: github.event_name == 'workflow_dispatch'
  540. needs:
  541. - build-images
  542. - gen-tags
  543. strategy:
  544. matrix:
  545. platform:
  546. - linux/amd64
  547. - linux/i386
  548. - linux/arm/v7
  549. - linux/arm64
  550. - linux/ppc64le
  551. runs-on: ubuntu-latest
  552. steps:
  553. - name: Checkout
  554. id: checkout
  555. uses: actions/checkout@v4
  556. with:
  557. fetch-depth: 0
  558. submodules: recursive
  559. - name: Generate Artifact Name
  560. id: artifact-name
  561. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  562. - name: Download Cache
  563. id: fetch-cache
  564. uses: actions/download-artifact@v4
  565. with:
  566. name: cache-${{ steps.artifact-name.outputs.platform }}
  567. path: /tmp/build-cache
  568. - name: Mark image as official
  569. id: env
  570. if: github.repository == 'netdata/netdata'
  571. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  572. - name: Setup QEMU
  573. id: qemu
  574. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  575. uses: docker/setup-qemu-action@v3
  576. - name: Setup Buildx
  577. id: prepare
  578. uses: docker/setup-buildx-action@v3
  579. - name: Registry Login
  580. id: login
  581. if: github.repository == 'netdata/netdata'
  582. uses: docker/login-action@v3
  583. with:
  584. registry: ghcr.io
  585. username: ${{ github.repository_owner }}
  586. password: ${{ secrets.GITHUB_TOKEN }}
  587. - name: Build Image
  588. id: build
  589. uses: docker/build-push-action@v6
  590. with:
  591. platforms: ${{ matrix.platform }}
  592. cache-from: type=local,src=/tmp/build-cache
  593. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  594. outputs: type=image,name=ghcr.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  595. - name: Export Digest
  596. id: export-digest
  597. if: github.repository == 'netdata/netdata'
  598. run: |
  599. mkdir -p /tmp/digests
  600. digest="${{ steps.build.outputs.digest }}"
  601. touch "/tmp/digests/${digest#sha256:}"
  602. - name: Upload digest
  603. id: upload-digest
  604. if: github.repository == 'netdata/netdata'
  605. uses: actions/upload-artifact@v4.6.0
  606. with:
  607. name: ghcr-digests-${{ steps.artifact-name.outputs.platform }}
  608. path: /tmp/digests/*
  609. if-no-files-found: error
  610. retention-days: 1
  611. - name: Failure Notification
  612. uses: rtCamp/action-slack-notify@v2
  613. env:
  614. SLACK_COLOR: 'danger'
  615. SLACK_FOOTER: ''
  616. SLACK_ICON_EMOJI: ':github-actions:'
  617. SLACK_TITLE: 'GHCR upload failed:'
  618. SLACK_USERNAME: 'GitHub Actions'
  619. SLACK_MESSAGE: |-
  620. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on GHCR failed.
  621. Checkout: ${{ steps.checkout.outcome }}
  622. Determine artifact name: ${{ steps.artifact-name.outcome }}
  623. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  624. Setup environment: ${{ steps.env.outcome }}
  625. Setup QEMU: ${{ steps.qemu.outcome }}
  626. Setup buildx: ${{ steps.prepare.outcome }}
  627. Login to registry: ${{ steps.login.outcome }}
  628. Build image: ${{ steps.build.outcome }}
  629. Export digest: ${{ steps.export-digest.outcome }}
  630. Upload digest: ${{ steps.upload-digest.outcome }}
  631. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  632. if: >-
  633. ${{
  634. failure()
  635. && github.repository == 'netdata/netdata'
  636. }}
  637. publish-ghcr:
  638. name: Consolidate and tag images for GHCR
  639. if: github.event_name == 'workflow_dispatch'
  640. needs:
  641. - build-images-ghcr
  642. - gen-tags
  643. runs-on: ubuntu-latest
  644. steps:
  645. - name: Checkout
  646. id: checkout
  647. uses: actions/checkout@v4
  648. - name: Download digests
  649. id: fetch-digests
  650. uses: actions/download-artifact@v4
  651. with:
  652. path: /tmp/digests
  653. pattern: ghcr-digests-*
  654. merge-multiple: true
  655. - name: Setup Buildx
  656. id: prepare
  657. uses: docker/setup-buildx-action@v3
  658. - name: Registry Login
  659. id: login
  660. if: github.repository == 'netdata/netdata'
  661. uses: docker/login-action@v3
  662. with:
  663. registry: ghcr.io
  664. username: ${{ github.repository_owner }}
  665. password: ${{ secrets.GITHUB_TOKEN }}
  666. - name: Create and Push Manifest
  667. id: manifest
  668. if: github.repository == 'netdata/netdata'
  669. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'ghcr.io' "${{ needs.gen-tags.outputs.tags }}")
  670. - name: Failure Notification
  671. uses: rtCamp/action-slack-notify@v2
  672. env:
  673. SLACK_COLOR: 'danger'
  674. SLACK_FOOTER: ''
  675. SLACK_ICON_EMOJI: ':github-actions:'
  676. SLACK_TITLE: 'Publishing Docker images on GHCR failed:'
  677. SLACK_USERNAME: 'GitHub Actions'
  678. SLACK_MESSAGE: |-
  679. ${{ github.repository }}: Publishing Docker images on GHCR failed.
  680. Checkout: ${{ steps.checkout.outcome }}
  681. Download digests: ${{ steps.fetch-digests.outcome }}
  682. Setup buildx: ${{ steps.prepare.outcome }}
  683. Login to registry: ${{ steps.login.outcome }}
  684. Create and push manifest: ${{ steps.manifest.outcome }}
  685. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  686. if: >-
  687. ${{
  688. failure()
  689. && github.repository == 'netdata/netdata'
  690. }}
  691. trigger-subsequent-workflows:
  692. if: github.event_name == 'workflow_dispatch'
  693. name: Trigger subsquent workflows for newly added versions
  694. needs:
  695. - publish-docker-hub
  696. - gen-tags
  697. runs-on: ubuntu-latest
  698. steps:
  699. - name: Checkout
  700. id: checkout
  701. uses: actions/checkout@v4
  702. with:
  703. submodules: recursive
  704. - name: Trigger Helmchart PR
  705. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  706. id: trigger-helmchart
  707. uses: benc-uk/workflow-dispatch@v1
  708. with:
  709. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  710. repo: netdata/helmchart
  711. workflow: Agent Version PR
  712. ref: refs/heads/master
  713. inputs: '{"agent_version": "v${{ inputs.version }}"}'
  714. - name: Trigger MSI build
  715. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  716. id: trigger-msi
  717. uses: benc-uk/workflow-dispatch@v1
  718. with:
  719. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  720. repo: netdata/msi-installer
  721. workflow: Build
  722. ref: refs/heads/master
  723. inputs: '{"tag": "stable", "pwd": "${{ secrets.MSI_CODE_SIGNING_PASSWORD }}"}'
  724. - name: Failure Notification
  725. uses: rtCamp/action-slack-notify@v2
  726. env:
  727. SLACK_COLOR: 'danger'
  728. SLACK_FOOTER: ''
  729. SLACK_ICON_EMOJI: ':github-actions:'
  730. SLACK_TITLE: ':'
  731. SLACK_USERNAME: 'GitHub Actions'
  732. SLACK_MESSAGE: |-
  733. ${{ github.repository }}: Version cascade failed
  734. Checkout: ${{ steps.checkout.outcome }}
  735. Trigger Helmchart PR: ${{ steps.trigger-helmchart.outcome }}
  736. Trigger MSI build: ${{ steps.trigger-msi.outcome }}
  737. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  738. if: >-
  739. ${{
  740. failure()
  741. && github.event_name != 'pull_request'
  742. && startsWith(github.ref, 'refs/heads/master')
  743. && github.repository == 'netdata/netdata'
  744. }}