Skip to content

Commit

Permalink
Push Antrea Ubuntu-based images to ghcr.io
Browse files Browse the repository at this point in the history
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
  • Loading branch information
antoninbas committed Nov 26, 2024
1 parent 18e9111 commit 1b657cb
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 55 deletions.
72 changes: 47 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand All @@ -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
Expand All @@ -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
Expand Down
84 changes: 54 additions & 30 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 1b657cb

Please sign in to comment.