diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a442781aab5..f18f8d00dd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,18 +71,30 @@ jobs: if: ${{ needs.check-env.outputs.push_needed == 'false' }} run: | ./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull - - name: Build and push Antrea Docker image to registry + - name: Login to Docker Hub + if: ${{ needs.check-env.outputs.push_needed == 'true' }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ needs.check-env.outputs.push_needed == 'true' }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Antrea Docker image to registries if: ${{ needs.check-env.outputs.push_needed == 'true' }} - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: | - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull --push-base-images - docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" - docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" - docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" - docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + + for registry in "docker.io" "ghcr.io"; do + docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" ${registry}/antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" ${registry}/antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + docker push ${registry}/antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + docker push ${registry}/antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + done # Same repository workflow dispatch to run conformance tests - name: Run conformance tests if: ${{ needs.check-env.outputs.push_needed == 'true' }} @@ -94,6 +106,9 @@ jobs: push-manifest: needs: [check-env, build] if: ${{ needs.check-env.outputs.push_needed == 'true' }} + strategy: + matrix: + registry: [docker.io, ghcr.io] runs-on: ubuntu-latest env: DOCKER_TAG: latest @@ -102,26 +117,33 @@ jobs: uses: docker/setup-buildx-action@v3 with: driver: ${{ needs.check-env.outputs.docker_driver }} - - name: Docker login - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + - name: Login to Docker Hub + if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'docker.io' }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'ghcr.io' }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Create and push manifest for controller image run: | - docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \ - antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \ - antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \ - antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}" - docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" + docker manifest create ${{ matrix.registry }}/antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}" + docker manifest push --purge ${{ matrix.registry }}/antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" - name: Create and push manifest for agent image run: | - docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \ - antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \ - antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \ - antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}" - docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" + docker manifest create ${{ matrix.registry }}/antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}" + docker manifest push --purge ${{ matrix.registry }}/antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" build-ubi: needs: check-env diff --git a/.github/workflows/build_tag.yml b/.github/workflows/build_tag.yml index 17d9ba2092e..3c4f77b3a9f 100644 --- a/.github/workflows/build_tag.yml +++ b/.github/workflows/build_tag.yml @@ -44,53 +44,77 @@ jobs: uses: docker/setup-buildx-action@v3 with: driver: docker - - name: Build and push Antrea Ubuntu Docker image to registry + - name: Build Antrea Ubuntu Docker image env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} VERSION: ${{ needs.get-version.outputs.version }} run: | ./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" - docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" - docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" - docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + - name: Login to Docker Hub + if: ${{ needs.check-env.outputs.push_needed == 'true' }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ needs.check-env.outputs.push_needed == 'true' }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Push Antrea Ubuntu Docker image to registries + run: | + for registry in "docker.io" "ghcr.io"; do + docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" ${registry}/antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" ${registry}/antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + docker push ${registry}/antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + docker push ${registry}/antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}" + done + # Same repository workflow dispatch to run conformance tests + - name: Run conformance tests + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: .github/workflows/conformance.yml + inputs: ${{ format('{{ "antrea-version":"{0}", "antrea-image-distro":"ubuntu", "test-suite":"conformance", "runner":"{1}", "antrea-image-platform":"{2}", "always-upload-logs":true }}', github.ref, matrix.runner, matrix.platform) }} push-manifest: needs: [get-version, build] + strategy: + matrix: + registry: [docker.io, ghcr.io] runs-on: ubuntu-latest env: DOCKER_TAG: ${{ needs.get-version.outputs.version }} steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Docker login - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + - name: Login to Docker Hub + if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'docker.io' }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == "ghcr.io" }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Create and push manifest for controller image run: | - docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \ - antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \ - antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \ - antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}" - docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" + docker manifest create ${{ matrix.registry }}/antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}" + docker manifest push --purge ${{ matrix.registry }}/antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" - name: Create and push manifest for agent image run: | - docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \ - antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \ - antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \ - antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}" - docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" - # Same repository workflow dispatch to run conformance tests - - name: Run conformance tests - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: .github/workflows/conformance.yml - inputs: ${{ format('{{ "antrea-version":"{0}", "antrea-image-distro":"ubuntu", "test-suite":"conformance", "runner":"{1}", "antrea-image-platform":"{2}", "always-upload-logs":true }}', github.ref, matrix.runner, matrix.platform) }} + docker manifest create ${{ matrix.registry }}/antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \ + ${{ matrix.registry }}/antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}" + docker manifest push --purge ${{ matrix.registry }}/antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" build-ubi: runs-on: [ubuntu-latest]