From e140a6bab27957791816cfd881c557acd2e76df0 Mon Sep 17 00:00:00 2001 From: lotyp Date: Sat, 6 Apr 2024 02:57:26 +0300 Subject: [PATCH] ci: changes --- .github/workflows/build.yml | 141 +++++++++++------------------------- 1 file changed, 41 insertions(+), 100 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab75a58..b3d95b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -176,105 +176,46 @@ jobs: ls -lah /tmp/digests/digests-8.1-fpm-alpine-amd64/ ls -lah /tmp/digests/digests-8.1-fpm-alpine-arm64/ -# - name: 🔑 Login to docker-hub -# uses: docker/login-action@v3 -# with: -# username: ${{ secrets.DOCKER_USERNAME }} -# password: ${{ secrets.DOCKER_TOKEN }} -# -# - name: 🔑 Login to GHCR -# uses: docker/login-action@v3 -# with: -# registry: ghcr.io -# username: ${{ github.repository_owner }} -# password: ${{ secrets.GITHUB_TOKEN }} -# -# - name: 🖥️ Setup docker QEMU -# uses: docker/setup-qemu-action@v3 -# with: -# platforms: linux/amd64,linux/arm64 -# -# - name: 🛠️ Set up Docker Buildx -# uses: docker/setup-buildx-action@v3 -# with: -# platforms: linux/amd64,linux/arm64 -# buildkitd-flags: "--debug" - -# - name: Create manifest list and push -# working-directory: /tmp/digests -# run: | -# docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.DOCKER_NAMESPACE }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \ -# $(printf '${{ env.DOCKERHUB_SLUG }}@sha256:%s ' *) -# docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.GHCR_NAMESPACE }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \ -# $(printf '${{ env.GHCR_SLUG }}@sha256:%s ' *) -# -# - name: Create manifest list and push -# run: | -# for FILE in $(find /tmp -name 'bake-meta-*.json'); do -# echo "Processing file: $FILE" -# cat "$FILE" | jq -# done -# -# for TAG in $TAGS; do -# echo "Processing tag: $TAG" -# FULL_TAGS=() -# for FILE in $(find /tmp -name 'bake-meta-*.json'); do -# echo "Processing file: $FILE" -# # Debug: Print the structure of the JSON file -# cat "$FILE" | jq -# -# REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1) -# DIGEST=$(jq -r --arg REPO "$REPO" '.["'$REPO'"]["containerimage.digest"]' $FILE) -# -# if [ "$DIGEST" == "null" ] || [ -z "$DIGEST" ]; then -# echo "Digest not found for $REPO in $FILE" -# continue # Skip adding this to FULL_TAGS -# fi -# -# echo "Adding $REPO@$DIGEST to FULL_TAGS" -# FULL_TAGS+=("$REPO@$DIGEST") -# done -# -# if [ ${#FULL_TAGS[@]} -eq 0 ]; then -# echo "No valid digests found for tag $TAG, skipping..." -# continue -# fi -# -# echo "FULL_TAGS for $TAG: ${FULL_TAGS[@]}" -# docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG" -# done - -# # Debug: List all matching meta files -# echo "Listing all bake-meta-*.json files for debugging:" -# ls -la /tmp/bake-meta-*.json -# -# # Aggregate all tags from the meta files -# TAGS=$(jq -r '.target."docker-metadata-action".tags[]' /tmp/bake-meta-*.json | sort -u) -# echo "Found tags: $TAGS" -# -# # Loop through each tag and create a manifest list -# for TAG in $TAGS; do -# echo "Processing tag: $TAG" -# FULL_TAGS=() -# for FILE in /tmp/bake-meta-*.json; do -# if [ -d "$FILE" ]; then -# echo "$FILE is a directory, skipping..." -# continue -# fi -# if jq -e --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE > /dev/null; then -# # Extract the repository and digest for the current platform -# REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1) -# DIGEST=$(jq -r '.["'$REPO'"]["containerimage.digest"]' $FILE) -# echo "Adding $REPO@$DIGEST to FULL_TAGS" -# FULL_TAGS+=("$REPO@$DIGEST") -# fi -# done -# -# # Debug: Print FULL_TAGS before creating the manifest -# echo "FULL_TAGS for $TAG: ${FULL_TAGS[@]}" -# -# # Create and push the manifest list for the current tag -# docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG" -# done + - name: 🔑 Login to docker-hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: 🔑 Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: 🖥️ Setup docker QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: 🛠️ Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 + buildkitd-flags: "--debug" + + - name: 🚀 Create manifest list and push + run: | + # Fetch digests for amd64 and arm64 architectures + DIGEST_AMD64=$(cat /tmp/digests/digests-8.1-fpm-alpine-amd64/*) + DIGEST_ARM64=$(cat /tmp/digests/digests-8.1-fpm-alpine-arm64/*) + echo "Digest AMD64: $DIGEST_AMD64" + echo "Digest ARM64: $DIGEST_ARM64" + + # Create the manifest list for Docker Hub + docker buildx imagetools create $(jq -cr ".target.\"docker-metadata-action\".tags | map(select(startswith(\"${DOCKER_NAMESPACE}\")) | \"-t \" + .) | join(\" \")" /tmp/bake-meta-8.1-fpm-alpine-amd64.json) \ + "${DOCKER_NAMESPACE}@sha256:${DIGEST_AMD64}" \ + "${DOCKER_NAMESPACE}@sha256:${DIGEST_ARM64}" + + # Create the manifest list for GHCR + docker buildx imagetools create $(jq -cr ".target.\"docker-metadata-action\".tags | map(select(startswith(\"${GHCR_NAMESPACE}\")) | \"-t \" + .) | join(\" \")" /tmp/bake-meta-8.1-fpm-alpine-amd64.json) \ + "${GHCR_NAMESPACE}@sha256:${DIGEST_AMD64}" \ + "${GHCR_NAMESPACE}@sha256:${DIGEST_ARM64}" ...