Skip to content

Commit

Permalink
ci: changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Apr 5, 2024
1 parent 7dfd61c commit e140a6b
Showing 1 changed file with 41 additions and 100 deletions.
141 changes: 41 additions & 100 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
...

0 comments on commit e140a6b

Please sign in to comment.