@@ -69,11 +69,16 @@ jobs:
6969 echo "Building all available extensions"
7070 fi
7171
72- - name : Process extensions
72+ - name : Extract extension data to files
7373 run : |
74- mkdir -p /tmp/extension_builds
7574 branch="${GITHUB_REF##*/}"
7675
76+ # Create empty files
77+ > /tmp/basenames.txt
78+ > /tmp/basetags.txt
79+ > /tmp/outnames.txt
80+ > /tmp/dirs.txt
81+
7782 for ext_file in $(echo "${{ steps.find_extensions.outputs.extensions }}"); do
7883 ext_dir=$(dirname "$ext_file")
7984 ext_name=$(basename "$ext_dir")
@@ -84,41 +89,63 @@ jobs:
8489 outname=$(yq '.container.outname' "$ext_file")
8590 base_image=$(yq '.container.base.image' "$ext_file")
8691
87- # Handle tags which could be a string, list, or map
88- tags=$(yq -o=json '.container.base.tag' "$ext_file")
92+ # Check if Dockerfile exists
93+ if [[ ! -f "$ext_dir/Dockerfile" ]]; then
94+ echo "::warning::No Dockerfile found for extension $ext_name, skipping"
95+ continue
96+ fi
97+
98+ # Handle tags
99+ tags_count=$(yq '.container.base.tag | length' "$ext_file")
89100
90- # Process tags based on their type
91- if [[ "$tags" == "null" ]]; then
92- tags="$branch"
93- elif [[ "$tags" == "{\"*\"}" ]]; then
94- # Handle object format like {"3.21", "devel"}
95- tags=$(echo "$tags" | jq -r 'keys | join(" ")')
96- elif [[ "$tags" == "[*]" ]]; then
97- # Handle array format
98- tags=$(echo "$tags" | jq -r 'join(" ")')
101+ # If no tags defined, use branch name as default tag
102+ if [[ $tags_count -eq 0 ]]; then
103+ echo "$outname" >> /tmp/outnames.txt
104+ echo "$base_image" >> /tmp/basenames.txt
105+ echo "$branch" >> /tmp/basetags.txt
106+ echo "$ext_dir" >> /tmp/dirs.txt
107+ else
108+ # For each tag, create a line in each file
109+ for (( i=0; i<$tags_count; i++ )); do
110+ tag=$(yq ".container.base.tag[$i]" "$ext_file")
111+ echo "$outname" >> /tmp/outnames.txt
112+ echo "$base_image" >> /tmp/basenames.txt
113+ echo "$tag" >> /tmp/basetags.txt
114+ echo "$ext_dir" >> /tmp/dirs.txt
115+ done
99116 fi
117+ done
118+
119+ echo "Files created with build data:"
120+ echo "===== Outnames ====="
121+ cat /tmp/outnames.txt
122+ echo "===== Base Images ====="
123+ cat /tmp/basenames.txt
124+ echo "===== Tags ====="
125+ cat /tmp/basetags.txt
126+ echo "===== Directories ====="
127+ cat /tmp/dirs.txt
128+
129+ - name : Build extensions
130+ run : |
131+ # Check if we have any extensions to build
132+ if [[ ! -s /tmp/outnames.txt ]]; then
133+ echo "No extensions to build"
134+ exit 0
135+ fi
136+
137+ # Process line by line with paste command
138+ paste /tmp/outnames.txt /tmp/basenames.txt /tmp/basetags.txt /tmp/dirs.txt | while read outname base_image tag ext_dir; do
139+ echo "Building $outname:$tag from $base_image:$tag using Dockerfile in $ext_dir"
100140
101- echo "Building extension $ext_name: $outname from $base_image with tags: $tags"
141+ # Build and push
142+ docker buildx build --platform linux/amd64 \
143+ -t "ghcr.io/${{ github.repository_owner }}/$outname:$tag" \
144+ -t "docker.io/${{ github.repository_owner }}/$outname:$tag" \
145+ --build-arg BASE_IMAGE=$base_image \
146+ --build-arg TAG=$tag \
147+ --push \
148+ "$ext_dir"
102149
103- # Process each tag
104- for tag in $tags; do
105- echo "Building for tag: $tag"
106-
107- # Check for Dockerfile in extension directory
108- if [ -f "$ext_dir/Dockerfile" ]; then
109- echo "Using extension Dockerfile at $ext_dir/Dockerfile"
110-
111- docker buildx build --platform linux/amd64 \
112- -t "ghcr.io/${{ github.repository_owner }}/$outname:$tag" \
113- -t "docker.io/${{ github.repository_owner }}/$outname:$tag" \
114- --build-arg BASE_IMAGE=$base_image \
115- --build-arg TAG=$tag \
116- --push \
117- "$ext_dir"
118-
119- echo "Successfully built and pushed $outname:$tag"
120- else
121- echo "No Dockerfile found for extension $ext_name"
122- fi
123- done
150+ echo "Successfully built and pushed $outname:$tag"
124151 done
0 commit comments