docker.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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. steps:
  35. - name: Checkout
  36. id: checkout
  37. if: github.event_name != 'workflow_dispatch'
  38. uses: actions/checkout@v4
  39. with:
  40. fetch-depth: 0
  41. submodules: recursive
  42. - name: Check files
  43. id: check-files
  44. if: github.event_name != 'workflow_dispatch'
  45. uses: tj-actions/changed-files@v43
  46. with:
  47. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  48. files: |
  49. **/*.c
  50. **/*.cc
  51. **/*.h
  52. **/*.hh
  53. **/*.in
  54. **/*.patch
  55. **/*.cmake
  56. .dockerignore
  57. CMakeLists.txt
  58. netdata-installer.sh
  59. .github/workflows/docker.yml
  60. .github/scripts/docker-test.sh
  61. .github/scripts/gen-docker-tags.py
  62. .github/scripts/gen-docker-imagetool-args.py
  63. packaging/cmake/
  64. packaging/docker/
  65. packaging/installer/
  66. packaging/runtime-check.sh
  67. packaging/*.version
  68. packaging/*.checksums
  69. src/aclk/aclk-schemas/
  70. src/ml/dlib/
  71. src/fluent-bit/
  72. src/web/server/h2o/libh2o/
  73. files_ignore: |
  74. netdata.spec.in
  75. **/*.md
  76. - name: List all changed files in pattern
  77. continue-on-error: true
  78. if: github.event_name != 'workflow_dispatch'
  79. env:
  80. ALL_CHANGED_FILES: ${{ steps.check-files.outputs.all_changed_files }}
  81. run: |
  82. for file in ${ALL_CHANGED_FILES}; do
  83. echo "$file was changed"
  84. done
  85. - name: Check Run
  86. id: check-run
  87. run: |
  88. if [ "${{ steps.check-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  89. echo 'run=true' >> "${GITHUB_OUTPUT}"
  90. else
  91. echo 'run=false' >> "${GITHUB_OUTPUT}"
  92. fi
  93. build-images:
  94. name: Build Docker Images
  95. needs:
  96. - file-check
  97. runs-on: ubuntu-latest
  98. strategy:
  99. matrix:
  100. platform:
  101. - linux/amd64
  102. - linux/i386
  103. - linux/arm/v7
  104. - linux/arm64
  105. - linux/ppc64le
  106. # Fail fast on releases, but run everything to completion on other triggers.
  107. fail-fast: ${{ github.event_name == 'workflow_dispatch' }}
  108. steps:
  109. - name: Skip Check
  110. id: skip
  111. if: needs.file-check.outputs.run != 'true'
  112. run: echo "SKIPPED"
  113. - name: Checkout
  114. id: checkout
  115. if: needs.file-check.outputs.run == 'true'
  116. uses: actions/checkout@v4
  117. with:
  118. fetch-depth: 0
  119. submodules: recursive
  120. - name: Generate Artifact Name
  121. id: artifact-name
  122. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  123. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  124. - name: Mark image as official
  125. id: env
  126. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  127. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  128. - name: Setup QEMU
  129. id: qemu
  130. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64' && needs.file-check.outputs.run == 'true'
  131. uses: docker/setup-qemu-action@v3
  132. - name: Setup Buildx
  133. id: prepare
  134. if: needs.file-check.outputs.run == 'true'
  135. uses: docker/setup-buildx-action@v3
  136. - name: Build Image
  137. id: build
  138. if: needs.file-check.outputs.run == 'true'
  139. uses: docker/build-push-action@v5
  140. with:
  141. platforms: ${{ matrix.platform }}
  142. tags: netdata/netdata:test
  143. load: true
  144. cache-to: type=local,dest=/tmp/build-cache,mode=max
  145. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  146. - name: Test Image
  147. id: test
  148. if: needs.file-check.outputs.run == 'true' && matrix.platform == 'linux/amd64'
  149. run: .github/scripts/docker-test.sh
  150. - name: Upload Cache
  151. id: upload-cache
  152. if: github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch'
  153. uses: actions/upload-artifact@v4
  154. with:
  155. name: cache-${{ steps.artifact-name.outputs.platform }}
  156. path: /tmp/build-cache/*
  157. retention-days: 1
  158. - name: Failure Notification
  159. uses: rtCamp/action-slack-notify@v2
  160. env:
  161. SLACK_COLOR: 'danger'
  162. SLACK_FOOTER: ''
  163. SLACK_ICON_EMOJI: ':github-actions:'
  164. SLACK_TITLE: 'Docker build failed:'
  165. SLACK_USERNAME: 'GitHub Actions'
  166. SLACK_MESSAGE: |-
  167. ${{ github.repository }}: Building or testing Docker image for ${{ matrix.platform }} failed.
  168. Checkout: ${{ steps.checkout.outcome }}
  169. Determine artifact name: ${{ steps.artifact-name.outcome }}
  170. Setup environment: ${{ steps.env.outcome }}
  171. Setup QEMU: ${{ steps.qemu.outcome }}
  172. Setup buildx: ${{ steps.prepare.outcome }}
  173. Build image: ${{ steps.build.outcome }}
  174. Test image: ${{ steps.test.outcome }}
  175. Upload build cache: ${{ steps.upload-cache.outcome }}
  176. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  177. if: >-
  178. ${{
  179. failure()
  180. && github.event_name != 'pull_request'
  181. && github.repository == 'netdata/netdata'
  182. && needs.file-check.outputs.run == 'true'
  183. }}
  184. gen-tags:
  185. name: Generate Docker Tags
  186. runs-on: ubuntu-latest
  187. if: github.event_name == 'workflow_dispatch'
  188. outputs:
  189. tags: ${{ steps.tag.outputs.tags }}
  190. steps:
  191. - name: Checkout
  192. id: checkout
  193. uses: actions/checkout@v4
  194. - name: Generate Tags
  195. id: tag
  196. run: |
  197. if [ ${{ github.event_name }} = 'workflow_dispatch' ]; then
  198. echo "tags=$(.github/scripts/gen-docker-tags.py ${{ github.event_name }} ${{ github.event.inputs.version }})" >> "${GITHUB_OUTPUT}"
  199. else
  200. echo "tags=$(.github/scripts/gen-docker-tags.py ${{ github.event_name }} '')" >> "${GITHUB_OUTPUT}"
  201. fi
  202. build-images-docker-hub:
  203. name: Push Images to Docker Hub
  204. if: github.event_name == 'workflow_dispatch'
  205. needs:
  206. - build-images
  207. - gen-tags
  208. strategy:
  209. matrix:
  210. platform:
  211. - linux/amd64
  212. - linux/i386
  213. - linux/arm/v7
  214. - linux/arm64
  215. - linux/ppc64le
  216. runs-on: ubuntu-latest
  217. steps:
  218. - name: Checkout
  219. id: checkout
  220. uses: actions/checkout@v4
  221. with:
  222. fetch-depth: 0
  223. submodules: recursive
  224. - name: Generate Artifact Name
  225. id: artifact-name
  226. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  227. - name: Download Cache
  228. id: fetch-cache
  229. uses: actions/download-artifact@v4
  230. with:
  231. name: cache-${{ steps.artifact-name.outputs.platform }}
  232. path: /tmp/build-cache
  233. - name: Mark image as official
  234. id: env
  235. if: github.repository == 'netdata/netdata'
  236. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  237. - name: Setup QEMU
  238. id: qemu
  239. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  240. uses: docker/setup-qemu-action@v3
  241. - name: Setup Buildx
  242. id: prepare
  243. uses: docker/setup-buildx-action@v3
  244. - name: Registry Login
  245. id: login
  246. if: github.repository == 'netdata/netdata'
  247. uses: docker/login-action@v3
  248. with:
  249. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  250. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  251. - name: Build Image
  252. id: build
  253. uses: docker/build-push-action@v5
  254. with:
  255. platforms: ${{ matrix.platform }}
  256. cache-from: type=local,src=/tmp/build-cache
  257. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  258. outputs: type=image,name=netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  259. - name: Export Digest
  260. id: export-digest
  261. if: github.repository == 'netdata/netdata'
  262. run: |
  263. mkdir -p /tmp/digests
  264. digest="${{ steps.build.outputs.digest }}"
  265. touch "/tmp/digests/${digest#sha256:}"
  266. - name: Upload digest
  267. id: upload-digest
  268. if: github.repository == 'netdata/netdata'
  269. uses: actions/upload-artifact@v4
  270. with:
  271. name: docker-digests-${{ steps.artifact-name.outputs.platform }}
  272. path: /tmp/digests/*
  273. if-no-files-found: error
  274. retention-days: 1
  275. - name: Failure Notification
  276. uses: rtCamp/action-slack-notify@v2
  277. env:
  278. SLACK_COLOR: 'danger'
  279. SLACK_FOOTER: ''
  280. SLACK_ICON_EMOJI: ':github-actions:'
  281. SLACK_TITLE: 'Docker Hub upload failed:'
  282. SLACK_USERNAME: 'GitHub Actions'
  283. SLACK_MESSAGE: |-
  284. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on Docker Hub failed.
  285. Checkout: ${{ steps.checkout.outcome }}
  286. Determine artifact name: ${{ steps.artifact-name.outcome }}
  287. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  288. Setup environment: ${{ steps.env.outcome }}
  289. Setup QEMU: ${{ steps.qemu.outcome }}
  290. Setup buildx: ${{ steps.prepare.outcome }}
  291. Login to registry: ${{ steps.login.outcome }}
  292. Build image: ${{ steps.build.outcome }}
  293. Export digest: ${{ steps.export-digest.outcome }}
  294. Upload digest: ${{ steps.upload-digest.outcome }}
  295. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  296. if: >-
  297. ${{
  298. failure()
  299. && github.repository == 'netdata/netdata'
  300. }}
  301. publish-docker-hub:
  302. name: Consolidate and tag images for DockerHub
  303. if: github.event_name == 'workflow_dispatch'
  304. needs:
  305. - build-images-docker-hub
  306. - gen-tags
  307. runs-on: ubuntu-latest
  308. steps:
  309. - name: Checkout
  310. id: checkout
  311. uses: actions/checkout@v4
  312. - name: Download digests
  313. id: fetch-digests
  314. uses: actions/download-artifact@v4
  315. with:
  316. path: /tmp/digests
  317. pattern: docker-digests-*
  318. merge-multiple: true
  319. - name: Setup Buildx
  320. id: prepare
  321. uses: docker/setup-buildx-action@v3
  322. - name: Registry Login
  323. id: login
  324. if: github.repository == 'netdata/netdata'
  325. uses: docker/login-action@v3
  326. with:
  327. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  328. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  329. - name: Create and Push Manifest
  330. id: manifest
  331. if: github.repository == 'netdata/netdata'
  332. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests '' ${{ needs.gen-tags.outputs.tags }})
  333. - name: Failure Notification
  334. uses: rtCamp/action-slack-notify@v2
  335. env:
  336. SLACK_COLOR: 'danger'
  337. SLACK_FOOTER: ''
  338. SLACK_ICON_EMOJI: ':github-actions:'
  339. SLACK_TITLE: 'Publishing Docker images to Docker Hub failed:'
  340. SLACK_USERNAME: 'GitHub Actions'
  341. SLACK_MESSAGE: |-
  342. ${{ github.repository }}: Publishing Docker images to Docker Hub failed.
  343. Checkout: ${{ steps.checkout.outcome }}
  344. Download digests: ${{ steps.fetch-digests.outcome }}
  345. Setup buildx: ${{ steps.prepare.outcome }}
  346. Login to registry: ${{ steps.login.outcome }}
  347. Create and push manifest: ${{ steps.manifest.outcome }}
  348. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  349. if: >-
  350. ${{
  351. failure()
  352. && github.repository == 'netdata/netdata'
  353. }}
  354. build-images-quay:
  355. name: Push Images to Quay.io
  356. if: github.event_name == 'workflow_dispatch'
  357. needs:
  358. - build-images
  359. - gen-tags
  360. strategy:
  361. matrix:
  362. platform:
  363. - linux/amd64
  364. - linux/i386
  365. - linux/arm/v7
  366. - linux/arm64
  367. - linux/ppc64le
  368. runs-on: ubuntu-latest
  369. steps:
  370. - name: Checkout
  371. id: checkout
  372. uses: actions/checkout@v4
  373. with:
  374. fetch-depth: 0
  375. submodules: recursive
  376. - name: Generate Artifact Name
  377. id: artifact-name
  378. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  379. - name: Download Cache
  380. id: fetch-cache
  381. uses: actions/download-artifact@v4
  382. with:
  383. name: cache-${{ steps.artifact-name.outputs.platform }}
  384. path: /tmp/build-cache
  385. - name: Mark image as official
  386. id: env
  387. if: github.repository == 'netdata/netdata'
  388. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  389. - name: Setup QEMU
  390. id: qemu
  391. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  392. uses: docker/setup-qemu-action@v3
  393. - name: Setup Buildx
  394. id: prepare
  395. uses: docker/setup-buildx-action@v3
  396. - name: Registry Login
  397. id: login
  398. if: github.repository == 'netdata/netdata'
  399. uses: docker/login-action@v3
  400. with:
  401. registry: quay.io
  402. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  403. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  404. - name: Build Image
  405. id: build
  406. uses: docker/build-push-action@v5
  407. with:
  408. platforms: ${{ matrix.platform }}
  409. cache-from: type=local,src=/tmp/build-cache
  410. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  411. outputs: type=image,name=quay.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  412. - name: Export Digest
  413. id: export-digest
  414. if: github.repository == 'netdata/netdata'
  415. run: |
  416. mkdir -p /tmp/digests
  417. digest="${{ steps.build.outputs.digest }}"
  418. touch "/tmp/digests/${digest#sha256:}"
  419. - name: Upload digest
  420. id: upload-digest
  421. if: github.repository == 'netdata/netdata'
  422. uses: actions/upload-artifact@v4
  423. with:
  424. name: quay-digests-${{ steps.artifact-name.outputs.platform }}
  425. path: /tmp/digests/*
  426. if-no-files-found: error
  427. retention-days: 1
  428. - name: Failure Notification
  429. uses: rtCamp/action-slack-notify@v2
  430. env:
  431. SLACK_COLOR: 'danger'
  432. SLACK_FOOTER: ''
  433. SLACK_ICON_EMOJI: ':github-actions:'
  434. SLACK_TITLE: 'Quay.io upload failed:'
  435. SLACK_USERNAME: 'GitHub Actions'
  436. SLACK_MESSAGE: |-
  437. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on Quay.io failed.
  438. Checkout: ${{ steps.checkout.outcome }}
  439. Determine artifact name: ${{ steps.artifact-name.outcome }}
  440. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  441. Setup environment: ${{ steps.env.outcome }}
  442. Setup QEMU: ${{ steps.qemu.outcome }}
  443. Setup buildx: ${{ steps.prepare.outcome }}
  444. Login to registry: ${{ steps.login.outcome }}
  445. Build image: ${{ steps.build.outcome }}
  446. Export digest: ${{ steps.export-digest.outcome }}
  447. Upload digest: ${{ steps.upload-digest.outcome }}
  448. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  449. if: >-
  450. ${{
  451. failure()
  452. && github.repository == 'netdata/netdata'
  453. }}
  454. publish-quay:
  455. name: Consolidate and tag images for Quay.io
  456. if: github.event_name == 'workflow_dispatch'
  457. needs:
  458. - build-images-quay
  459. - gen-tags
  460. runs-on: ubuntu-latest
  461. steps:
  462. - name: Checkout
  463. id: checkout
  464. uses: actions/checkout@v4
  465. - name: Download digests
  466. id: fetch-digests
  467. uses: actions/download-artifact@v4
  468. with:
  469. path: /tmp/digests
  470. pattern: quay-digests-*
  471. merge-multiple: true
  472. - name: Setup Buildx
  473. id: prepare
  474. uses: docker/setup-buildx-action@v3
  475. - name: Registry Login
  476. id: login
  477. if: github.repository == 'netdata/netdata'
  478. uses: docker/login-action@v3
  479. with:
  480. registry: quay.io
  481. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  482. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  483. - name: Create and Push Manifest
  484. id: manifest
  485. if: github.repository == 'netdata/netdata'
  486. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'quay.io' ${{ needs.gen-tags.outputs.tags }})
  487. - name: Failure Notification
  488. uses: rtCamp/action-slack-notify@v2
  489. env:
  490. SLACK_COLOR: 'danger'
  491. SLACK_FOOTER: ''
  492. SLACK_ICON_EMOJI: ':github-actions:'
  493. SLACK_TITLE: 'Publishing Docker images on Quay.io failed:'
  494. SLACK_USERNAME: 'GitHub Actions'
  495. SLACK_MESSAGE: |-
  496. ${{ github.repository }}: Publishing Docker images on Quay.io failed.
  497. Checkout: ${{ steps.checkout.outcome }}
  498. Download digests: ${{ steps.fetch-digests.outcome }}
  499. Setup buildx: ${{ steps.prepare.outcome }}
  500. Login to registry: ${{ steps.login.outcome }}
  501. Create and push manifest: ${{ steps.manifest.outcome }}
  502. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  503. if: >-
  504. ${{
  505. failure()
  506. && github.repository == 'netdata/netdata'
  507. }}
  508. build-images-ghcr:
  509. name: Push Images to GHCR
  510. if: github.event_name == 'workflow_dispatch'
  511. needs:
  512. - build-images
  513. - gen-tags
  514. strategy:
  515. matrix:
  516. platform:
  517. - linux/amd64
  518. - linux/i386
  519. - linux/arm/v7
  520. - linux/arm64
  521. - linux/ppc64le
  522. runs-on: ubuntu-latest
  523. steps:
  524. - name: Checkout
  525. id: checkout
  526. uses: actions/checkout@v4
  527. with:
  528. fetch-depth: 0
  529. submodules: recursive
  530. - name: Generate Artifact Name
  531. id: artifact-name
  532. run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
  533. - name: Download Cache
  534. id: fetch-cache
  535. uses: actions/download-artifact@v4
  536. with:
  537. name: cache-${{ steps.artifact-name.outputs.platform }}
  538. path: /tmp/build-cache
  539. - name: Mark image as official
  540. id: env
  541. if: github.repository == 'netdata/netdata'
  542. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  543. - name: Setup QEMU
  544. id: qemu
  545. if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
  546. uses: docker/setup-qemu-action@v3
  547. - name: Setup Buildx
  548. id: prepare
  549. uses: docker/setup-buildx-action@v3
  550. - name: Registry Login
  551. id: login
  552. if: github.repository == 'netdata/netdata'
  553. uses: docker/login-action@v3
  554. with:
  555. registry: ghcr.io
  556. username: ${{ github.repository_owner }}
  557. password: ${{ secrets.GITHUB_TOKEN }}
  558. - name: Build Image
  559. id: build
  560. uses: docker/build-push-action@v5
  561. with:
  562. platforms: ${{ matrix.platform }}
  563. cache-from: type=local,src=/tmp/build-cache
  564. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  565. outputs: type=image,name=ghcr.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
  566. - name: Export Digest
  567. id: export-digest
  568. if: github.repository == 'netdata/netdata'
  569. run: |
  570. mkdir -p /tmp/digests
  571. digest="${{ steps.build.outputs.digest }}"
  572. touch "/tmp/digests/${digest#sha256:}"
  573. - name: Upload digest
  574. id: upload-digest
  575. if: github.repository == 'netdata/netdata'
  576. uses: actions/upload-artifact@v4
  577. with:
  578. name: ghcr-digests-${{ steps.artifact-name.outputs.platform }}
  579. path: /tmp/digests/*
  580. if-no-files-found: error
  581. retention-days: 1
  582. - name: Failure Notification
  583. uses: rtCamp/action-slack-notify@v2
  584. env:
  585. SLACK_COLOR: 'danger'
  586. SLACK_FOOTER: ''
  587. SLACK_ICON_EMOJI: ':github-actions:'
  588. SLACK_TITLE: 'GHCR upload failed:'
  589. SLACK_USERNAME: 'GitHub Actions'
  590. SLACK_MESSAGE: |-
  591. ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on GHCR failed.
  592. Checkout: ${{ steps.checkout.outcome }}
  593. Determine artifact name: ${{ steps.artifact-name.outcome }}
  594. Fetch build cache: ${{ steps.fetch-cache.outcome }}
  595. Setup environment: ${{ steps.env.outcome }}
  596. Setup QEMU: ${{ steps.qemu.outcome }}
  597. Setup buildx: ${{ steps.prepare.outcome }}
  598. Login to registry: ${{ steps.login.outcome }}
  599. Build image: ${{ steps.build.outcome }}
  600. Export digest: ${{ steps.export-digest.outcome }}
  601. Upload digest: ${{ steps.upload-digest.outcome }}
  602. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  603. if: >-
  604. ${{
  605. failure()
  606. && github.repository == 'netdata/netdata'
  607. }}
  608. publish-ghcr:
  609. name: Consolidate and tag images for GHCR
  610. if: github.event_name == 'workflow_dispatch'
  611. needs:
  612. - build-images-quay
  613. - gen-tags
  614. runs-on: ubuntu-latest
  615. steps:
  616. - name: Checkout
  617. id: checkout
  618. uses: actions/checkout@v4
  619. - name: Download digests
  620. id: fetch-digests
  621. uses: actions/download-artifact@v4
  622. with:
  623. path: /tmp/digests
  624. pattern: ghcr-digests-*
  625. merge-multiple: true
  626. - name: Setup Buildx
  627. id: prepare
  628. uses: docker/setup-buildx-action@v3
  629. - name: Registry Login
  630. id: login
  631. if: github.repository == 'netdata/netdata'
  632. uses: docker/login-action@v3
  633. with:
  634. registry: ghcr.io
  635. username: ${{ github.repository_owner }}
  636. password: ${{ secrets.GITHUB_TOKEN }}
  637. - name: Create and Push Manifest
  638. id: manifest
  639. if: github.repository == 'netdata/netdata'
  640. run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'ghcr.io' ${{ needs.gen-tags.outputs.tags }})
  641. - name: Failure Notification
  642. uses: rtCamp/action-slack-notify@v2
  643. env:
  644. SLACK_COLOR: 'danger'
  645. SLACK_FOOTER: ''
  646. SLACK_ICON_EMOJI: ':github-actions:'
  647. SLACK_TITLE: 'Publishing Docker images on GHCR failed:'
  648. SLACK_USERNAME: 'GitHub Actions'
  649. SLACK_MESSAGE: |-
  650. ${{ github.repository }}: Publishing Docker images on GHCR failed.
  651. Checkout: ${{ steps.checkout.outcome }}
  652. Download digests: ${{ steps.fetch-digests.outcome }}
  653. Setup buildx: ${{ steps.prepare.outcome }}
  654. Login to registry: ${{ steps.login.outcome }}
  655. Create and push manifest: ${{ steps.manifest.outcome }}
  656. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  657. if: >-
  658. ${{
  659. failure()
  660. && github.repository == 'netdata/netdata'
  661. }}