add cleanup fix danser video renaming
This commit is contained in:
88
.gitea/actions/cleanup/action.yml
Normal file
88
.gitea/actions/cleanup/action.yml
Normal file
@@ -0,0 +1,88 @@
|
||||
name: "Cleanup Extra Files"
|
||||
description: "Remove leftover or outdated assets from repository"
|
||||
|
||||
inputs:
|
||||
all_skins:
|
||||
description: "Newline-delimited list of all skins"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Cleanup Extra Files
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "[Cleanup Extra Files Started]"
|
||||
|
||||
readarray -t skins <<< "${{ inputs.all_skins }}"
|
||||
|
||||
[ -f how-to-use.md ] && rm -f how-to-use.md
|
||||
[ -f src/replay.osr ] && rm -f src/replay.osr
|
||||
[ -d src/default-skin ] && rm -rf src/default-skin
|
||||
|
||||
sanitize_filename() {
|
||||
echo "$1" | \
|
||||
tr -d '\000-\037' | \
|
||||
sed -e 's#[\\/:\*\?"<>|]#-#g' | \
|
||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
|
||||
}
|
||||
|
||||
prune_dir() {
|
||||
local root="$1"
|
||||
local skin="$2"
|
||||
local expected="$3"
|
||||
|
||||
for f in "$root"/*; do
|
||||
[ -f "$f" ] || continue
|
||||
name="$(basename "$f")"
|
||||
if printf '%s\n' "${skins[@]}" | grep -Fxq -- "$name"; then
|
||||
continue
|
||||
fi
|
||||
echo " → Removing unexpected root file: $f"
|
||||
rm -f "$f"
|
||||
done
|
||||
|
||||
dir="$root/$skin"
|
||||
[ -d "$dir" ] || return
|
||||
for f in "$dir"/*; do
|
||||
[ -e "$f" ] || continue
|
||||
if [[ "$(basename "$f")" != "$expected" ]]; then
|
||||
echo " → Removing unexpected file: $f"
|
||||
rm -f "$f"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
for root in "$REPO_SCREENSHOT_DIR" "$REPO_RANKING_PANEL_DIR" "$REPO_MOD_ICONS_DIR" "$REPO_THUMBNAIL_DIR" "$OSK_PATH" "$DOC_DIR"; do
|
||||
[ -d "$root" ] || continue
|
||||
for dir in "$root"/*; do
|
||||
[ -d "$dir" ] || continue
|
||||
name="$(basename "$dir")"
|
||||
if ! printf '%s\n' "${skins[@]}" | grep -Fxq -- "$name"; then
|
||||
echo " → Skin '$name' deleted—removing directory $dir"
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
for skin in "${skins[@]}"; do
|
||||
header=$(sanitize_filename "$skin")
|
||||
ini=$(find "$DANSER_SKINS_DIR/$skin" -maxdepth 1 -type f -iname "skin.ini" -print -quit || true)
|
||||
if [[ -f "$ini" ]]; then
|
||||
raw=$(grep -i '^[[:space:]]*Name:' "$ini" | head -n1 || true)
|
||||
raw="${raw#*:}"
|
||||
raw="$(echo "$raw" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
||||
tmp_header=$(sanitize_filename "$raw")
|
||||
[[ -n "$tmp_header" ]] && header="$tmp_header"
|
||||
fi
|
||||
|
||||
prune_dir "$REPO_SCREENSHOT_DIR" "$skin" "$header.mp4"
|
||||
prune_dir "$REPO_RANKING_PANEL_DIR" "$skin" "$header.webp"
|
||||
prune_dir "$REPO_MOD_ICONS_DIR" "$skin" "$header-mod-icons.webp"
|
||||
prune_dir "$REPO_THUMBNAIL_DIR" "$skin" "$header.webp"
|
||||
prune_dir "$OSK_PATH" "$skin" "$header.osk"
|
||||
prune_dir "$DOC_DIR" "$skin" "$header.md"
|
||||
done
|
||||
|
||||
echo "[Cleanup Extra Files Complete]"
|
||||
@@ -3,7 +3,7 @@ description: "Generate Danser videos, screenshots, thumbnails, and rename them b
|
||||
|
||||
inputs:
|
||||
changed_skins_file:
|
||||
description: "Path to file with changed skins"
|
||||
description: "Path to JSON file containing changed skins"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
@@ -19,19 +19,12 @@ 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; }
|
||||
|
||||
SKIN_COUNT=${#skins[@]}
|
||||
INDEX=1
|
||||
|
||||
sanitize_filename() {
|
||||
echo "$1" | \
|
||||
tr -d '\000-\037' | \
|
||||
sed -e 's#[\\/:\*\?"<>|]#-#g' | \
|
||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
|
||||
}
|
||||
|
||||
for skin_path in "${skins[@]}"; do
|
||||
[ -z "$skin_path" ] && continue
|
||||
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
||||
@@ -105,8 +98,49 @@ runs:
|
||||
echo " ✖ No thumbnail PNG found for $SKIN_NAME"
|
||||
fi
|
||||
|
||||
# --- Renaming Section ---
|
||||
skin_header="$SKIN_NAME"
|
||||
INDEX=$((INDEX + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "[Danser Job Finished — processed $SKIN_COUNT skins]"
|
||||
|
||||
- name: Rename Generated Assets Based on skin.ini
|
||||
shell: bash
|
||||
run: |
|
||||
echo "[Asset Renaming Job Started]"
|
||||
|
||||
if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
|
||||
echo "No skins changed. Skipping asset renaming."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Load skins from JSON
|
||||
mapfile -t skins < <(jq -r '.[]' "${{ inputs.changed_skins_file }}")
|
||||
[ "${#skins[@]}" -eq 0 ] && { echo "No skins to rename. Exiting."; exit 0; }
|
||||
|
||||
SKIN_COUNT=${#skins[@]}
|
||||
INDEX=1
|
||||
|
||||
sanitize_filename() {
|
||||
echo "$1" | \
|
||||
tr -d '\000-\037' | \
|
||||
sed -e 's#[\\/:\*\?"<>|]#-#g' | \
|
||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
|
||||
}
|
||||
|
||||
for skin_path in "${skins[@]}"; do
|
||||
[ -z "$skin_path" ] && continue
|
||||
SKIN_DIR_NAME="$skin_path"
|
||||
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
||||
|
||||
if [ ! -d "$SKIN_DIR" ]; then
|
||||
echo "Skipping missing skin directory: $SKIN_DIR"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing skin $INDEX/$SKIN_COUNT: $SKIN_DIR_NAME"
|
||||
|
||||
skin_header="$SKIN_DIR_NAME"
|
||||
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
|
||||
if [ -f "$ini_file" ]; then
|
||||
name_line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true)
|
||||
@@ -146,4 +180,4 @@ runs:
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "[Danser Job Finished — processed $SKIN_COUNT skins]"
|
||||
echo "[Asset Renaming Complete — processed $SKIN_COUNT skins]"
|
||||
|
||||
Reference in New Issue
Block a user