expect json

This commit is contained in:
2025-10-01 15:19:55 +02:00
parent 34be25888e
commit c1a5162536
3 changed files with 21 additions and 24 deletions

View File

@@ -32,7 +32,6 @@ runs:
| sed 's|'"$SKINS_DIR"'/||'
)
# Convert to compact JSON
json=$(printf '%s\n' "${skins[@]}" | jq -R . | jq -cs .)
{
@@ -121,25 +120,22 @@ runs:
echo " ✓ ${#uniq_skins[@]} valid skin names after cleaning"
echo ""
echo "[Writing Changed Skins to File]"
changed_skins_file=$(mktemp)
if [ "${#uniq_skins[@]}" -eq 0 ]; then
echo "→ No added/modified skins detected."
{
echo "changed_skins_file<<EOF"
echo ""
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo "[]" > "$changed_skins_file"
else
echo "[Writing Changed Skins to File]"
changed_skins_file=$(mktemp)
printf "%s\n" "${uniq_skins[@]}" > "$changed_skins_file"
echo " ✓ Skins written to $changed_skins_file"
{
echo "changed_skins_file<<EOF"
echo "$changed_skins_file"
echo "EOF"
} >> "$GITHUB_OUTPUT"
printf '%s\n' "${uniq_skins[@]}" | jq -R . | jq -cs . > "$changed_skins_file"
echo " ✓ Skins written to $changed_skins_file (JSON array)"
fi
{
echo "changed_skins_file<<EOF"
echo "$changed_skins_file"
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo ""
echo "[Detect Changed Skin Directories Complete — ${#uniq_skins[@]} skins processed, ${#deleted_skins[@]} skins deleted]"

View File

@@ -3,7 +3,7 @@ description: "Generate WEBP mod icons from skins and convert panel/thumbnail PNG
inputs:
changed_skins_file:
description: "Path to file with changed skins"
description: "Path to file containing changed skins (JSON array)"
required: true
runs:
@@ -19,7 +19,7 @@ runs:
exit 0
fi
mapfile -t skin_dirs < "${{ inputs.changed_skins_file }}"
mapfile -t skin_dirs < <(jq -r '.[]' "${{ inputs.changed_skins_file }}")
[ "${#skin_dirs[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; }
sanitize_filename() {
@@ -80,7 +80,6 @@ runs:
elif [ -f "${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png" ]; then
file="${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png"
fi
[ -n "$file" ] && montage_files+=("$file")
done
@@ -121,7 +120,7 @@ runs:
exit 0
fi
mapfile -t skins < "${{ inputs.changed_skins_file }}"
mapfile -t skins < <(jq -r '.[]' "${{ inputs.changed_skins_file }}")
[ "${#skins[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; }
convert_pngs_to_webp() {

View File

@@ -3,7 +3,7 @@ description: "Pull only LFS objects for changed skins and core assets"
inputs:
changed_skins_file:
description: "Path to file containing changed skins"
description: "Path to file containing changed skins (JSON array)"
required: false
default: ""
@@ -18,15 +18,17 @@ runs:
exit 0
fi
mapfile -t skins < <(jq -r '.[]' "${{ inputs.changed_skins_file }}")
[ "${#skins[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; }
includes="src/**,export/**,media/**"
skin_includes=$(
while IFS= read -r skin; do
for skin in "${skins[@]}"; do
esc=$(printf '%s' "$skin" \
| sed -e 's/\[/\\[/g' -e 's/\]/\\]/g')
printf 'Skins/%s/**\n' "$esc"
done < "${{ inputs.changed_skins_file }}" \
| paste -sd ','
done | paste -sd ','
)
includes="$includes,$skin_includes"