name: Extract Archives run-name: Extract Archives on: workflow_dispatch: push: branches: - master paths: - "cars/**" # Only run if archives in cars/ change env: GIT_DEFAULT_HASH: sha1 jobs: prepare-server-content: runs-on: ubuntu-latest steps: - name: Pre-initialize Repository with SHA-1 run: | mkdir -p ${{ github.workspace }} git init --object-format=sha1 ${{ github.workspace }} - name: Checkout Master Branch (LFS) env: # This token is automatically provided by Gitea/GitHub Actions TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # 1. Clean workspace explicitly to be safe rm -rf ./* ./.git # 2. Initialize specifically with SHA-1 git init --object-format=sha1 # 3. Add remote with authentication embedded # Use the environment variable to keep the log clean git remote add origin "https://$TOKEN@git.dapa.hu/dapa/assetto.git" # 4. Fetch the specific branch (depth 1 for speed) git fetch --depth=1 origin master # 5. Checkout the branch git checkout master # 6. Initialize LFS and pull files # Note: If this fails, it confirms the files are missing from the server (see below) git lfs install git lfs pull # - name: Checkout Master Branch (LFS) # uses: actions/checkout@v4 # with: # ref: master # lfs: true # fetch-depth: 0 # clean: false - name: Install 7-Zip run: | sudo apt-get update sudo apt-get install -y p7zip-full - name: Process Archives run: | # Define Paths SOURCE_ROOT="./cars" # This is where the server expects the files DEST_ROOT="./server-data/content/cars" mkdir -p "$DEST_ROOT" echo "Searching for archives in $SOURCE_ROOT..." # Find all archives recursively (zip, 7z, rar) find "$SOURCE_ROOT" -type f \( -name "*.zip" -o -name "*.7z" -o -name "*.rar" \) | while read archive; do # Get the filename without extension (e.g., "cars/groupA/my_car.zip" -> "my_car") filename=$(basename -- "$archive") car_name="${filename%.*}" echo "--------------------------------------" echo "Processing: $car_name" # Create a temp directory for extraction temp_dir=$(mktemp -d) # Extract contents 7z x "$archive" -o"$temp_dir" -y > /dev/null # FILTERING LOGIC find "$temp_dir" -type f -not -name "skins/*/livery.png" \ -not -name "skins/*/preview.jpeg" \ -not -name "skins/*/ui_skin.json" \ -not -name "ui/badge.png" \ -not -name "ui/ui_car.json" \ -not -name "data.acd" \ -not -name "physics/standard/data.acd" \ -not -name "physics/csp/data.acd" \ -delete tree "$temp_dir" # # 5. Move to final Server Directory # target_dir="$DEST_ROOT/$car_name" # # Clean old version if exists # if [ -d "$target_dir" ]; then # rm -rf "$target_dir" # fi # mkdir -p "$target_dir" # # Move files # cp -r "$temp_dir"/* "$target_dir"/ # # Cleanup temp # rm -rf "$temp_dir" echo "✅ Installed to: $target_dir" done # - name: Verify Installation # run: | # echo "📁Final Server Directory Structure:" # # Show directory tree 3 levels deep to verify structure without spamming files # find ./server-data -maxdepth 3 -not -path '*/.*'