Skip to content

Commit

Permalink
Improvements Deploy script #5
Browse files Browse the repository at this point in the history
  • Loading branch information
r-martins committed Aug 7, 2024
1 parent 8d9cf5f commit a00321c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/scripts/syncPlugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export LANG=en_US.UTF-8
# List installed plugins with version
wp plugin list --fields=name,version --allow-root > installed_plugins.txt

# Extract names and versions of plugins to be synchronized
grep -oP '"name": "\K[^"]+' .github/workflows/plugins.json > plugins_to_sync.txt
grep -oP '"version": "\K[^"]+' .github/workflows/plugins.json >> plugins_to_sync.txt
# Extract names, versions, and statuses of plugins to be synchronized
grep -oP '"name": "\K[^"]+' .github/workflows/plugins.json > plugins_to_sync_names.txt
grep -oP '"version": "\K[^"]+' .github/workflows/plugins.json > plugins_to_sync_versions.txt
grep -oP '"status": "\K[^"]+' .github/workflows/plugins.json > plugins_to_sync_statuses.txt

# Combine names, versions, and statuses into a single file
paste -d, plugins_to_sync_names.txt plugins_to_sync_versions.txt plugins_to_sync_statuses.txt > plugins_to_sync.txt

# Debug: Print the content of plugins_to_sync.txt
echo "Plugins to sync:"
Expand All @@ -21,24 +25,16 @@ echo "Currently installed plugins:"
cat installed_plugins.txt

# Process each plugin to be synchronized
while IFS= read -r name; do
# Read the version from the next line
read -r version

# Debug: Print the current plugin name and version
echo "Processing plugin: $name, Version: $version"
while IFS=, read -r name version status; do
# Debug: Print the current plugin name, version, and status
echo "Processing plugin: $name, Version: $version, Status: $status"

# Check if the plugin is already installed with the same version
if grep -q "$name,$version" installed_plugins.txt; then
echo "Plugin $name is already installed with version $version. Skipping."
continue
fi

status=$(grep -A 3 "\"name\": \"$name\"" .github/workflows/plugins.json | grep -oP '"status": "\K[^"]+')

# Debug: Print the status
echo "Status: $status"

if ! grep -q "$name" installed_plugins.txt; then
echo "Installing plugin: $name"
wp plugin install "$name" --version="$version" --allow-root
Expand Down

0 comments on commit a00321c

Please sign in to comment.