From b5a350474046366efb5809dd00aa4226333613e1 Mon Sep 17 00:00:00 2001 From: YIN JIA YI Date: Mon, 11 Sep 2023 01:00:00 +0800 Subject: [PATCH] feat(ci): add global container registry (#26) * feat(ci): add global container registry * fix(swr): update buildx provenance to false --- .github/workflows/container.yml | 95 ++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 2283699b..90e8c947 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -10,6 +10,13 @@ on: env: REGISTRY: ghcr.io EULIX_REGISTRY: hub.eulix.xyz + HUAWEICLOUD_REGISTRY_SH: swr.cn-east-3.myhuaweicloud.com + HUAWEICLOUD_REGISTRY_BJ: swr.cn-north-4.myhuaweicloud.com + HUAWEICLOUD_REGISTRY_GZ: swr.cn-south-1.myhuaweicloud.com + HUAWEICLOUD_REGISTRY_HK: swr.ap-southeast-1.myhuaweicloud.com + HUAWEICLOUD_REGISTRY_SG: swr.ap-southeast-3.myhuaweicloud.com + HUAWEICLOUD_REGISTRY_AF: swr.af-south-1.myhuaweicloud.com + HUAWEICLOUD_REGISTRY_LA: swr.la-north-2.myhuaweicloud.com IMAGE_NAME: ${{ github.repository }} jobs: @@ -65,6 +72,9 @@ jobs: - name: Setup Docker buildx uses: docker/setup-buildx-action@v2 + - run: echo "GITHUB_REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + shell: bash + - name: Inspect builder run: | echo "Name: ${{ steps.buildx.outputs.name }}" @@ -89,6 +99,69 @@ jobs: username: ${{ secrets.EULIX_REGISTRY_USERNAME }} password: ${{ secrets.EULIX_REGISTRY_PASSWORD }} + - name: Log into registry Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_REGISTRY_USERNAME }} + password: ${{ secrets.DOCKER_HUB_REGISTRY_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_SH }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_SH }} + username: cn-east-3@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_BJ }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_BJ }} + username: cn-north-4@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_GZ }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_GZ }} + username: cn-south-1@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_SG }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_SG }} + username: ap-southeast-3@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_HK }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_HK }} + username: ap-southeast-1@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_AF }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_AF }} + username: af-south-1@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + + - name: Log into registry ${{ env.HUAWEICLOUD_REGISTRY_LA }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.HUAWEICLOUD_REGISTRY_LA }} + username: la-north-2@${{ secrets.HUAWEICLOUD_USERNAME }} + password: ${{ secrets.HUAWEICLOUD_PASSWORD }} + - name: Extract Docker metadata for Server id: meta-server uses: docker/metadata-action@v2 @@ -96,12 +169,20 @@ jobs: images: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} ${{ env.EULIX_REGISTRY }}/${{ env.IMAGE_NAME }} + aospace/${{ env.GITHUB_REPOSITORY_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_SH }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_BJ }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_GZ }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_HK }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_SG }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_AF }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_LA }}/${{ env.IMAGE_NAME }} flavor: | prefix=server- - name: Build and push Docker image for Server id: build-and-push-server - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4.2.1 with: context: . push: ${{ github.event_name != 'pull_request' }} @@ -112,6 +193,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max file: Dockerfile-server + provenance: false - name: Extract Docker metadata for Client id: meta-client @@ -120,12 +202,20 @@ jobs: images: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} ${{ env.EULIX_REGISTRY }}/${{ env.IMAGE_NAME }} + aospace/${{ env.GITHUB_REPOSITORY_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_SH }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_BJ }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_GZ }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_HK }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_SG }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_AF }}/${{ env.IMAGE_NAME }} + ${{ env.HUAWEICLOUD_REGISTRY_LA }}/${{ env.IMAGE_NAME }} flavor: | prefix=client- - name: Build and push Docker image for Client id: build-and-push-client - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4.2.1 with: context: . push: ${{ github.event_name != 'pull_request' }} @@ -136,6 +226,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max file: Dockerfile-client + provenance: false - name: Extract Docker metadata for Server id: meta-opensource-server