-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add prepare zips and fix premissions
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |