From bee50d839410fae1cb93e141a30b5c01eaefdd3d Mon Sep 17 00:00:00 2001 From: yiannistri <8741709+yiannistri@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:08:46 +0000 Subject: [PATCH] ci: Push test images to ghcr.io instead of ttl.sh --- .github/workflows/e2e-branch.yaml | 47 +++++++---------------------- .github/workflows/e2e-workflow.yaml | 4 ++- Makefile | 18 +++++------ 3 files changed, 23 insertions(+), 46 deletions(-) diff --git a/.github/workflows/e2e-branch.yaml b/.github/workflows/e2e-branch.yaml index 624721f0..f420fa59 100644 --- a/.github/workflows/e2e-branch.yaml +++ b/.github/workflows/e2e-branch.yaml @@ -26,7 +26,6 @@ jobs: e2e-tests: env: BRANCH: ${{ inputs.branch }} - REPO: ttl.sh/aks-operator-ci runs-on: ubuntu-latest steps: - name: Checkout code @@ -34,47 +33,23 @@ jobs: with: ref: | ${{ env.BRANCH }} - - name: Export tag - id: export_tag - run: | - TAG="v0.0.0" - COMMITDATE=`date -d @$(git log -n1 --format="%at") "+%FT%TZ"` - COMMIT=`git rev-parse HEAD` - COMMIT_SHORT=`git rev-parse --short HEAD` - echo "operator_tag=$TAG" >> $GITHUB_OUTPUT - echo "commit_date=$COMMITDATE" >> $GITHUB_OUTPUT - echo "commit=$COMMIT" >> $GITHUB_OUTPUT - echo "commit_short=$COMMIT_SHORT" >> $GITHUB_OUTPUT - - name: Docker meta - id: meta - uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 + - name: Login to GHCR registry + uses: docker/login-action@v3 with: - images: | - ${{ env.REPO }} - tags: | - type=raw,value=${{ steps.export_tag.outputs.operator_tag }}-${{ steps.export_tag.outputs.commit_short }} - - name: Set up Docker Buildx - id: buildx + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Docker Buildx uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 - name: Build and push image - uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0 - with: - context: . - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - target: aks-operator - file: test/e2e/Dockerfile.e2e - build-args: | - TAG=${{ steps.export_tag.outputs.operator_tag }} - COMMITDATE=${{ steps.export_tag.outputs.commit_date }} - COMMIT=${{ steps.export_tag.outputs.commit }} + env: + REPO: ghcr.io/rancher + run: | + make image-push - name: Install Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.23.x - uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0 with: version: v0.23.0 diff --git a/.github/workflows/e2e-workflow.yaml b/.github/workflows/e2e-workflow.yaml index e89c906c..e1b1c9e1 100644 --- a/.github/workflows/e2e-workflow.yaml +++ b/.github/workflows/e2e-workflow.yaml @@ -3,7 +3,9 @@ on: workflow_dispatch: schedule: - cron: 0 22 * * * -permissions: read-all +permissions: + contents: read + packages: write # Required for pushing images to ghcr.io jobs: e2e-test-main: uses: ./.github/workflows/e2e-branch.yaml diff --git a/Makefile b/Makefile index 02758e59..d671f12d 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ TAG?=${GIT_TAG}-${GIT_COMMIT_SHORT} OPERATOR_CHART?=$(shell find $(ROOT_DIR) -type f -name "rancher-aks-operator-[0-9]*.tgz" -print) CRD_CHART?=$(shell find $(ROOT_DIR) -type f -name "rancher-aks-operator-crd*.tgz" -print) CHART_VERSION?=900 # Only used in e2e to avoid downgrades from rancher -REPO?=docker.io/rancher/aks-operator -IMAGE = $(REPO):$(TAG) +REPO?=docker.io/rancher +IMAGE = $(REPO)/aks-operator:$(TAG) MACHINE := rancher # Define the target platforms that can be used across the ecosystem. # Note that what would actually be used for a given project will be @@ -119,7 +119,7 @@ operator-chart: mkdir -p $(BIN_DIR) cp -rf $(ROOT_DIR)/charts/aks-operator $(BIN_DIR)/chart sed -i -e 's/tag:.*/tag: '${TAG}'/' $(BIN_DIR)/chart/values.yaml - sed -i -e 's|repository:.*|repository: '${REPO}'|' $(BIN_DIR)/chart/values.yaml + sed -i -e 's|repository:.*|repository: '${REPO}/aks-operator'|' $(BIN_DIR)/chart/values.yaml helm package --version ${CHART_VERSION} --app-version ${GIT_TAG} -d $(BIN_DIR)/ $(BIN_DIR)/chart rm -Rf $(BIN_DIR)/chart @@ -142,15 +142,15 @@ buildx-machine: ## create rancher dockerbuildx machine targeting platform define .PHONY: image-build image-build: buildx-machine ## build (and load) the container image targeting the current platform. docker buildx build -f package/Dockerfile \ - --builder $(MACHINE) --build-arg COMMIT=$(GIT_COMMIT) --build-arg VERSION=$(TAG) \ - -t "$(IMAGE)" $(BUILD_ACTION) . + --builder $(MACHINE) --build-arg COMMIT=$(GIT_COMMIT) --build-arg VERSION=$(TAG) \ + -t "$(IMAGE)" $(BUILD_ACTION) . @echo "Built $(IMAGE)" .PHONY: image-push image-push: buildx-machine ## build the container image targeting all platforms defined by TARGET_PLATFORMS and push to a registry. docker buildx build -f package/Dockerfile \ - --builder $(MACHINE) $(IID_FILE_FLAG) $(BUILDX_ARGS) --build-arg VERSION=$(TAG) \ - --platform=$(TARGET_PLATFORMS) -t "$(IMAGE)" --push . + --builder $(MACHINE) $(IID_FILE_FLAG) $(BUILDX_ARGS) --build-arg COMMIT=$(GIT_COMMIT) --build-arg VERSION=$(TAG) \ + --platform=$(TARGET_PLATFORMS) -t "$(IMAGE)" --push . @echo "Pushed $(IMAGE)" .PHONY: setup-kind @@ -168,7 +168,7 @@ e2e-tests: $(GINKGO) charts .PHONY: kind-e2e-tests kind-e2e-tests: docker-build-e2e setup-kind - kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG} + kind load docker-image --name $(CLUSTER_NAME) ${IMAGE} $(MAKE) e2e-tests kind-deploy-operator: @@ -181,7 +181,7 @@ docker-build-e2e: --build-arg "TAG=${GIT_TAG}" \ --build-arg "COMMIT=${GIT_COMMIT}" \ --build-arg "COMMITDATE=${COMMITDATE}" \ - -t ${REPO}:${TAG} . + -t ${IMAGE} . .PHOHY: delete-local-kind-cluster delete-local-kind-cluster: ## Delete the local kind cluster