Skip to content

Commit

Permalink
add prepare zips and fix premissions
Browse files Browse the repository at this point in the history
  • Loading branch information
vcanales committed Apr 5, 2024
1 parent 9d48f38 commit 9aea6f9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Empty file modified bin/generate-preview-links.sh
100644 → 100755
Empty file.
48 changes: 48 additions & 0 deletions bin/prepare-zips.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Directory where ZIP files will be stored
zip_dir="./theme_zips"
mkdir -p "$zip_dir"

# Temp file to store paths of created ZIPs
zip_paths_temp="./zip_paths.txt"
> "$zip_paths_temp" # Clear file content

# Function to check if a directory contains a WordPress theme
is_theme_directory() {
local dir=$1
if [[ -f "$dir/style.css" ]]; then
# Look for a line in style.css that starts with "Theme Name:"
grep -q "Theme Name:" "$dir/style.css"
return $?
fi
return 1
}

# Loop through each directory at the root level
for dir in */ ; do
if is_theme_directory "$dir"; then
theme_name=${dir%/} # Remove trailing slash
zip_file="${zip_dir}/${theme_name}.zip"

# Create ZIP file
(cd "$dir" && zip -r "../${zip_file}" . -x "*.git*" "*.DS_Store*")

# Save path of the created ZIP file
echo "$zip_file" >> "$zip_paths_temp"
fi
done

# Read the temp file line by line and format output for GitHub Actions
zip_paths=""
while IFS= read -r line; do
zip_paths="${zip_paths},${line}"
done < "$zip_paths_temp"

# Output the ZIP paths for GitHub Actions
# Trim leading comma
zip_paths="${zip_paths#,}"
echo "::set-output name=zip_paths::$zip_paths"

# Clean up
rm "$zip_paths_temp"

0 comments on commit 9aea6f9

Please sign in to comment.