Update .gitea/actions/discover-skins/action.yml

This commit is contained in:
2025-11-22 22:52:42 +01:00
parent 4a8c2fb2cf
commit 49b9f522a3

View File

@@ -22,24 +22,11 @@ outputs:
runs:
using: "composite"
steps:
- name: Checkout caller repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
fetch-depth: 0
path: .
- name: Fetch tags manually
shell: bash
run: |
git fetch origin --tags --force --prune
git tag -l
- name: Discover all skins
id: discover_all
shell: bash
run: |
echo "Discovering all skins in $SKINS_DIR…"
all_skins_file="/tmp/all_skins_shared.json"
find "$SKINS_DIR" -mindepth 1 -maxdepth 1 -type d -print0 \
| while IFS= read -r -d '' dir; do basename "$dir"; done \
@@ -57,6 +44,7 @@ runs:
shell: bash
run: |
set -e
echo "[Detect Changed Skin Directories Started]"
all_skins_file="/tmp/all_skins_shared.json"
temp_all_skins="/tmp/all_skins_raw_$RANDOM.txt"
@@ -69,50 +57,79 @@ runs:
skins=()
deleted_skins=()
echo "→ Force rebuild flag: $force_rebuild"
echo "→ Target skins input: $target_skins"
if [[ "$force_rebuild" == "true" ]]; then
echo "→ Force rebuild enabled. Using full list"
skins=("${all_skins[@]}")
elif [[ -n "$target_skins" && "$target_skins" != "" ]]; then
echo "→ Using target_skins input"
temp_target_file="/tmp/target_skins_$RANDOM.json"
printf '%s' "$target_skins" > "$temp_target_file"
mapfile -t skins < <(jq -r '.[]' "$temp_target_file")
rm -f "$temp_target_file"
echo "✓ Found ${#skins[@]} skin(s) from target_skins input"
else
echo "→ No rebuild flags set. Finding latest git tag..."
latest_tag=$(git tag --sort=-version:refname | head -n 1)
if [[ -n "$latest_tag" ]]; then
echo "→ Latest tag found: $latest_tag"
echo "→ Finding added/modified skins since $latest_tag…"
mapfile -t skins < <(
git diff --name-only -z --diff-filter=AM "$latest_tag" HEAD \
| while IFS= read -r -d '' file; do
[[ $file == Skins/* ]] && echo "${file#Skins/}" | cut -d/ -f1
done | sort -u
)
echo "✓ Found ${#skins[@]} added/modified skins"
echo "→ Finding deleted skins since $latest_tag…"
mapfile -t deleted_skins < <(
git diff --name-only -z --diff-filter=D "$latest_tag" HEAD \
| while IFS= read -r -d '' file; do
[[ $file == Skins/* ]] && echo "${file#Skins/}" | cut -d/ -f1
done | sort -u
)
if [ "${#deleted_skins[@]}" -gt 0 ]; then
for d in "${deleted_skins[@]}"; do
echo "→ Skin '$d' was deleted"
done
else
echo "✓ No skins deleted"
fi
else
echo "→ No tag found. Falling back to ALL_SKINS_DIR…"
skins=("${all_skins[@]}")
echo "✓ Found ${#skins[@]} skin directories (from ALL_SKINS_DIR)"
fi
fi
echo ""
echo "[Cleaning Skin Names]"
uniq_skins=()
for skin in "${skins[@]}"; do
skin="${skin#"${skin%%[![:space:]]*}"}"
skin="${skin%"${skin##*[![:space:]]}"}"
[[ -n "$skin" ]] && uniq_skins+=("$skin")
done
echo "✓ ${#uniq_skins[@]} valid skin names after cleaning"
echo ""
echo "[Writing Changed Skins to File]"
changed_skins_file="/tmp/changed_skins_$RANDOM.txt"
if [ "${#uniq_skins[@]}" -eq 0 ]; then
echo "→ No added/modified skins detected."
echo "[]" > "$changed_skins_file"
else
printf '%s\n' "${uniq_skins[@]}" | jq -R . | jq -cs . > "$changed_skins_file"
echo "✓ Skins written to $changed_skins_file"
fi
{
@@ -120,3 +137,6 @@ runs:
echo "$changed_skins_file"
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo ""
echo "[Detect Changed Skin Directories Complete — ${#uniq_skins[@]} skins processed, ${#deleted_skins[@]} skins deleted]"