Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Push test images to ghcr.io instead of ttl.sh #816

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 11 additions & 36 deletions .github/workflows/e2e-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,30 @@ jobs:
e2e-tests:
env:
BRANCH: ${{ inputs.branch }}
REPO: ttl.sh/aks-operator-ci
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
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
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
Loading