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 4a9f627 commit 7b4f4a2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/release-rbac-images-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ on:

permissions:
contents: read
packages: write
packages: write,read


jobs:
check-and-build:
kube-rbac-proxy-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -44,18 +45,26 @@ jobs:
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
Expand Down

0 comments on commit 7b4f4a2

Please sign in to comment.