diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cfb7d07d7e..d773b9b229 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,97 +2,108 @@ name: Docker on: push: - # Publish `master` as Docker `latest` image. branches: - master - - # Publish `v1.2.3` tags as releases. + - release-* tags: - - v* + - v*.*.* # Run tests for any PRs. pull_request: -env: - IMAGE_NAME: argo-rollouts - jobs: - # Run tests. - # See also https://docs.docker.com/docker-hub/builds/automated-testing/ - test: + docker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Run tests - run: | - if [ -f docker-compose.test.yml ]; then - docker-compose --file docker-compose.test.yml build - docker-compose --file docker-compose.test.yml run sut - else - docker build . --file Dockerfile - fi - - # Push image to GitHub Packages. - # See also https://docs.docker.com/docker-hub/builds/ - push: - # Ensure test job passes before pushing image. - needs: test + - name: Checkout + uses: actions/checkout@v2 - runs-on: ubuntu-latest - if: github.event_name == 'push' - - steps: - - uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx - id: buildx uses: docker/setup-buildx-action@v1 - with: - install: true - version: latest - - name: Set up QEMU - id: qemu - uses: docker/setup-qemu-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 with: - image: tonistiigi/binfmt:latest - platforms: all + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Build image - run: docker build . --file Dockerfile --tag $IMAGE_NAME + - name: Login to Quay.io + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_ROBOT_TOKEN }} - - name: Log into GitHub Container Registry - # TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT` - run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Generate tag - id: generate_tag + - name: Docker meta (controller) + id: controller-meta + uses: crazy-max/ghaction-docker-meta@v2 + with: + images: | + quay.io/argoproj/argo-rollouts + ghcr.io/argoproj/argo-rollouts + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + + - name: Docker meta (plugin) + id: plugin-meta + uses: crazy-max/ghaction-docker-meta@v2 + with: + images: | + quay.io/argoproj/kubectl-argo-rollouts + ghcr.io/argoproj/kubectl-argo-rollouts + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + + # avoid building linux/arm64 for PRs since it takes so long + - name: Set Platform Matrix + id: platform-matrix run: | - IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - - # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + PLATFORM_MATRIX=linux/amd64 + if [ ${{ github.event_name != 'pull_request' }} = true ]; then + PLATFORM_MATRIX=$PLATFORM_MATRIX,linux/arm64 + fi + echo "::set-output name=platform-matrix::$PLATFORM_MATRIX" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION + - name: Build and push (controller) + uses: docker/build-push-action@v2 + with: + platforms: ${{ steps.platform-matrix.outputs.platform-matrix }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.controller-meta.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new - echo ::set-output name=tag::$(echo $IMAGE_ID:$VERSION) - - name: Build and push image + - name: Build and push (plugin) uses: docker/build-push-action@v2 with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{steps.generate_tag.outputs.tag}} + target: kubectl-argo-rollouts + platforms: ${{ steps.platform-matrix.outputs.platform-matrix }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.plugin-meta.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/Makefile b/Makefile index a25f2373ce..b01661c6f3 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ endif ifeq (${DOCKER_PUSH},true) ifndef IMAGE_NAMESPACE -$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=argoproj)) +$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=quay.io/argoproj)) endif endif diff --git a/manifests/base/argo-rollouts-deployment.yaml b/manifests/base/argo-rollouts-deployment.yaml index 9a17f27f64..4f8dc2e7eb 100644 --- a/manifests/base/argo-rollouts-deployment.yaml +++ b/manifests/base/argo-rollouts-deployment.yaml @@ -18,7 +18,7 @@ spec: serviceAccountName: argo-rollouts containers: - name: argo-rollouts - image: argoproj/argo-rollouts:latest + image: quay.io/argoproj/argo-rollouts:latest imagePullPolicy: Always ports: - containerPort: 8090 diff --git a/manifests/base/kustomization.yaml b/manifests/base/kustomization.yaml index 274e8eb0f8..783d899ec8 100644 --- a/manifests/base/kustomization.yaml +++ b/manifests/base/kustomization.yaml @@ -7,5 +7,5 @@ resources: - argo-rollouts-aggregate-roles.yaml - argo-rollouts-metrics-service.yaml images: -- name: argoproj/argo-rollouts +- name: quay.io/argoproj/argo-rollouts newTag: latest diff --git a/manifests/install.yaml b/manifests/install.yaml index 7fbba22b54..e423e56ebb 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -12811,7 +12811,7 @@ spec: app.kubernetes.io/name: argo-rollouts spec: containers: - - image: argoproj/argo-rollouts:latest + - image: quay.io/argoproj/argo-rollouts:latest imagePullPolicy: Always name: argo-rollouts ports: diff --git a/manifests/namespace-install.yaml b/manifests/namespace-install.yaml index 2c4c0e7924..2cf1e8ce26 100644 --- a/manifests/namespace-install.yaml +++ b/manifests/namespace-install.yaml @@ -12812,7 +12812,7 @@ spec: containers: - args: - --namespaced - image: argoproj/argo-rollouts:latest + image: quay.io/argoproj/argo-rollouts:latest imagePullPolicy: Always name: argo-rollouts ports: