name: "Discover and Detect Skins" description: "Find all skins and detect which ones changed since last tag or based on inputs" inputs: force_rebuild: description: "Force rebuild all skins" required: false default: "false" target_skins: description: "JSON array of skins to rebuild (e.g., '[\"skin1\", \"skin2\"]')" required: false default: "" outputs: changed_skins_file: description: "Path to file containing changed skins" value: ${{ steps.detect.outputs.changed_skins_file }} all_skins: description: "All discovered skins (JSON array)" value: ${{ steps.discover_all.outputs.all_skins }} 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: | 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 \ | jq -R . | jq -cs . > "$all_skins_file" json=$(cat "$all_skins_file") { echo "all_skins<> "$GITHUB_OUTPUT" echo "all_skins_file=$all_skins_file" >> "$GITHUB_OUTPUT" - name: Detect Changed Skin Directories id: detect shell: bash run: | set -e all_skins_file="/tmp/all_skins_shared.json" temp_all_skins="/tmp/all_skins_raw_$RANDOM.txt" jq -r '.[]' "$all_skins_file" > "$temp_all_skins" mapfile -t all_skins < "$temp_all_skins" rm -f "$temp_all_skins" force_rebuild='${{ inputs.force_rebuild }}' target_skins='${{ inputs.target_skins }}' skins=() deleted_skins=() if [[ "$force_rebuild" == "true" ]]; then skins=("${all_skins[@]}") elif [[ -n "$target_skins" && "$target_skins" != "" ]]; then 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" else latest_tag=$(git tag --sort=-version:refname | head -n 1) if [[ -n "$latest_tag" ]]; then 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 ) 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 ) else skins=("${all_skins[@]}") fi fi uniq_skins=() for skin in "${skins[@]}"; do skin="${skin#"${skin%%[![:space:]]*}"}" skin="${skin%"${skin##*[![:space:]]}"}" [[ -n "$skin" ]] && uniq_skins+=("$skin") done changed_skins_file="/tmp/changed_skins_$RANDOM.txt" if [ "${#uniq_skins[@]}" -eq 0 ]; then echo "[]" > "$changed_skins_file" else printf '%s\n' "${uniq_skins[@]}" | jq -R . | jq -cs . > "$changed_skins_file" fi { echo "changed_skins_file<> "$GITHUB_OUTPUT"