Skip to content

Commit

Permalink
🌱 Add process to build the images for kube-rbac-proxy and publish in …
Browse files Browse the repository at this point in the history
…GitHub rehistry
  • Loading branch information
camilamacedo86 committed Apr 8, 2024
1 parent fb1922f commit 9f0f79b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/release-rbac-images-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ permissions:
contents: read
packages: write


jobs:
check-and-build:
kube-rbac-proxy-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -39,24 +40,34 @@ jobs:
- name: Install yq for YAML processing
run: sudo snap install yq

- name: Read versions from YAML and push images for each architecture
- name: Pull, Tag, and Push Images
run: |
VERSIONS=$(yq e '.versions[]' hack/release/kube-rbac-proxy/images-versions.yaml)
ARCHES=("amd64" "arm64" "ppc64le" "s390x")
VERSIONS=$(yq e '.versions[]' hack/release/kube-rbac-proxy/images-versions.yaml)
for VERSION in $VERSIONS; do
# Check if the multi-architecture manifest already exists
MANIFEST_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://ghcr.io/v2/kubernetes-sigs/kubebuilder/kube-rbac-proxy/manifests/$VERSION")
if [ "$MANIFEST_EXISTS" -eq 200 ]; then
echo "Manifest for version $VERSION already exists. Skipping..."
continue
fi
for ARCH in "${ARCHES[@]}"; do
SOURCE_IMAGE_TAG="quay.io/brancz/kube-rbac-proxy:$VERSION"
TARGET_IMAGE_TAG="ghcr.io/${{ github.repository_owner }}/kube-rbac-proxy:$VERSION-$ARCH"
TARGET_IMAGE_TAG="ghcr.io/kubernetes-sigs/kubebuilder/kube-rbac-proxy:$VERSION-$ARCH"
docker pull $SOURCE_IMAGE_TAG
docker tag $SOURCE_IMAGE_TAG $TARGET_IMAGE_TAG
docker push $TARGET_IMAGE_TAG
done
# Create and push a multi-architecture manifest
TARGET_IMAGE_TAG="ghcr.io/${{ github.repository_owner }}/kube-rbac-proxy:$VERSION"
docker manifest create $TARGET_IMAGE_TAG $(printf "ghcr.io/${{ github.repository_owner }}/kube-rbac-proxy:$VERSION-%s " "${ARCHES[@]}")
TARGET_IMAGE_TAG="ghcr.io/kubernetes-sigs/kubebuilder/kube-rbac-proxy:$VERSION"
docker manifest create $TARGET_IMAGE_TAG $(printf "ghcr.io/kubernetes-sigs/kubebuilder/kube-rbac-proxy:$VERSION-%s " "${ARCHES[@]}")
for ARCH in "${ARCHES[@]}"; do
docker manifest annotate $TARGET_IMAGE_TAG "ghcr.io/${{ github.repository_owner }}/kube-rbac-proxy:$VERSION-$ARCH" --arch $ARCH
docker manifest annotate $TARGET_IMAGE_TAG "ghcr.io/kubernetes-sigs/kubebuilder/kube-rbac-proxy:$VERSION-$ARCH" --arch $ARCH
done
docker manifest push $TARGET_IMAGE_TAG
done
shell: bash
env:
DOCKER_CLI_EXPERIMENTAL: enabled
2 changes: 1 addition & 1 deletion hack/release/kube-rbac-proxy/images-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Update this file to build new release for the images
# of the project https://github.com/brancz/kube-rbac-proxy
versions:
- v0.16.0
- v0.16.0

0 comments on commit 9f0f79b

Please sign in to comment.