@cryptotaxi247 / netdata-1 / commits / 9f72d128a

Switch publishing Docker images to regular repo.

Austin S. Hemmelgarn committed Mar 6, 2024 at 14:16 UTC 9f72d128a9cf1798a399b4310f5327ad3634d3bf
2 files changed +161 -5
.github/scripts/gen-docker-tags.py
+2 -2
@@ -5,12 +5,12 @@ import sys
5 github_event = sys.argv[1]
6 version = sys.argv[2]
7
8 -REPO = 'netdata/netdata-ci-test'
8 +REPO = 'netdata/netdata'
9
10 REPOS = (
11 REPO,
12 - # f'ghcr.io/{REPO}',
12 f'quay.io/{REPO}',
13 + f'ghcr.io/{REPO}',
14 )
15
16 match version:
.github/workflows/docker.yml
+159 -3
@@ -258,7 +258,7 @@ jobs:
258 platforms: ${{ matrix.platform }}
259 cache-from: type=local,src=/tmp/build-cache
260 build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
261 - outputs: type=image,name=netdata/netdata-ci-test,push-by-digest=true,name-canonical=true,push=true
261 + outputs: type=image,name=netdata/netdata,push-by-digest=true,name-canonical=true,push=true
262 - name: Export Digest
263 id: export-digest
264 if: github.repository == 'netdata/netdata'
@@ -413,7 +413,7 @@ jobs:
413 platforms: ${{ matrix.platform }}
414 cache-from: type=local,src=/tmp/build-cache
415 build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
416 - outputs: type=image,name=quay.io/netdata/netdata-ci-test,push-by-digest=true,name-canonical=true,push=true
416 + outputs: type=image,name=quay.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
417 - name: Export Digest
418 id: export-digest
419 if: github.repository == 'netdata/netdata'
@@ -489,7 +489,7 @@ jobs:
489 - name: Create and Push Manifest
490 id: manifest
491 if: github.repository == 'netdata/netdata'
492 - run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests '' ${{ needs.gen-tags.outputs.tags }})
492 + run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'quay.io' ${{ needs.gen-tags.outputs.tags }})
493 - name: Failure Notification
494 uses: rtCamp/action-slack-notify@v2
495 env:
@@ -511,3 +511,159 @@ jobs:
511 failure()
512 && github.repository == 'netdata/netdata'
513 }}
514 +
515 + build-images-ghcr:
516 + name: Push Images to GHCR
517 + if: github.event_name == 'workflow_dispatch'
518 + needs:
519 + - build-images
520 + - gen-tags
521 + strategy:
522 + matrix:
523 + platform:
524 + - linux/amd64
525 + - linux/i386
526 + - linux/arm/v7
527 + - linux/arm64
528 + - linux/ppc64le
529 + runs-on: ubuntu-latest
530 + steps:
531 + - name: Checkout
532 + id: checkout
533 + uses: actions/checkout@v4
534 + with:
535 + fetch-depth: 0
536 + submodules: recursive
537 + - name: Generate Artifact Name
538 + id: artifact-name
539 + run: echo "platform=$(echo ${{ matrix.platform }} | tr '/' '-' | cut -f 2- -d '-')" >> "${GITHUB_OUTPUT}"
540 + - name: Download Cache
541 + id: fetch-cache
542 + uses: actions/download-artifact@v4
543 + with:
544 + name: cache-${{ steps.artifact-name.outputs.platform }}
545 + path: /tmp/build-cache
546 + - name: Mark image as official
547 + id: env
548 + if: github.repository == 'netdata/netdata'
549 + run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
550 + - name: Setup QEMU
551 + id: qemu
552 + if: matrix.platform != 'linux/i386' && matrix.platform != 'linux/amd64'
553 + uses: docker/setup-qemu-action@v3
554 + - name: Setup Buildx
555 + id: prepare
556 + uses: docker/setup-buildx-action@v3
557 + - name: Registry Login
558 + id: login
559 + if: github.repository == 'netdata/netdata'
560 + uses: docker/login-action@v3
561 + with:
562 + registry: ghcr.io
563 + username: ${{ github.username }}
564 + password: ${{ secrets.GITHUB_TOKEN }}
565 + - name: Build Image
566 + id: build
567 + uses: docker/build-push-action@v5
568 + with:
569 + platforms: ${{ matrix.platform }}
570 + cache-from: type=local,src=/tmp/build-cache
571 + build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
572 + outputs: type=image,name=ghcr.io/netdata/netdata,push-by-digest=true,name-canonical=true,push=true
573 + - name: Export Digest
574 + id: export-digest
575 + if: github.repository == 'netdata/netdata'
576 + run: |
577 + mkdir -p /tmp/digests
578 + digest="${{ steps.build.outputs.digest }}"
579 + touch "/tmp/digests/${digest#sha256:}"
580 + - name: Upload digest
581 + id: upload-digest
582 + if: github.repository == 'netdata/netdata'
583 + uses: actions/upload-artifact@v4
584 + with:
585 + name: ghcr-digests-${{ steps.artifact-name.outputs.platform }}
586 + path: /tmp/digests/*
587 + if-no-files-found: error
588 + retention-days: 1
589 + - name: Failure Notification
590 + uses: rtCamp/action-slack-notify@v2
591 + env:
592 + SLACK_COLOR: 'danger'
593 + SLACK_FOOTER: ''
594 + SLACK_ICON_EMOJI: ':github-actions:'
595 + SLACK_TITLE: 'GHCR upload failed:'
596 + SLACK_USERNAME: 'GitHub Actions'
597 + SLACK_MESSAGE: |-
598 + ${{ github.repository }}: Creating or uploading Docker image for ${{ matrix.platform }} on GHCR failed.
599 + Checkout: ${{ steps.checkout.outcome }}
600 + Determine artifact name: ${{ steps.artifact-name.outcome }}
601 + Fetch build cache: ${{ steps.fetch-cache.outcome }}
602 + Setup environment: ${{ steps.env.outcome }}
603 + Setup QEMU: ${{ steps.qemu.outcome }}
604 + Setup buildx: ${{ steps.prepare.outcome }}
605 + Login to registry: ${{ steps.login.outcome }}
606 + Build image: ${{ steps.build.outcome }}
607 + Export digest: ${{ steps.export-digest.outcome }}
608 + Upload digest: ${{ steps.upload-digest.outcome }}
609 + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
610 + if: >-
611 + ${{
612 + failure()
613 + && github.repository == 'netdata/netdata'
614 + }}
615 +
616 + publish-ghcr:
617 + name: Consolidate and tag images for GHCR
618 + if: github.event_name == 'workflow_dispatch'
619 + needs:
620 + - build-images-quay
621 + - gen-tags
622 + runs-on: ubuntu-latest
623 + steps:
624 + - name: Checkout
625 + id: checkout
626 + uses: actions/checkout@v4
627 + - name: Download digests
628 + id: fetch-digests
629 + uses: actions/download-artifact@v4
630 + with:
631 + path: /tmp/digests
632 + pattern: ghcr-digests-*
633 + merge-multiple: true
634 + - name: Setup Buildx
635 + id: prepare
636 + uses: docker/setup-buildx-action@v3
637 + - name: Registry Login
638 + id: login
639 + if: github.repository == 'netdata/netdata'
640 + uses: docker/login-action@v3
641 + with:
642 + registry: quay.io
643 + username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
644 + password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
645 + - name: Create and Push Manifest
646 + id: manifest
647 + if: github.repository == 'netdata/netdata'
648 + run: docker buildx imagetools create $(.github/scripts/gen-docker-imagetool-args.py /tmp/digests 'ghcr.io' ${{ needs.gen-tags.outputs.tags }})
649 + - name: Failure Notification
650 + uses: rtCamp/action-slack-notify@v2
651 + env:
652 + SLACK_COLOR: 'danger'
653 + SLACK_FOOTER: ''
654 + SLACK_ICON_EMOJI: ':github-actions:'
655 + SLACK_TITLE: 'Publishing Docker images on GHCR failed:'
656 + SLACK_USERNAME: 'GitHub Actions'
657 + SLACK_MESSAGE: |-
658 + ${{ github.repository }}: Publishing Docker images on GHCR failed.
659 + Checkout: ${{ steps.checkout.outcome }}
660 + Download digests: ${{ steps.fetch-digests.outcome }}
661 + Setup buildx: ${{ steps.prepare.outcome }}
662 + Login to registry: ${{ steps.login.outcome }}
663 + Create and push manifest: ${{ steps.manifest.outcome }}
664 + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
665 + if: >-
666 + ${{
667 + failure()
668 + && github.repository == 'netdata/netdata'
669 + }}