-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetch-shops.sh
executable file
·58 lines (44 loc) · 2.06 KB
/
fetch-shops.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
command -v git
# Check if git is installed
if ! command -v git &> /dev/null; then
echo "git needs to be installed."
exit 1 # Exit with error code 1
fi
# Array of version tags to be downloaded
declare -A versions=( ["5.3.0"]="1" ["5.3.7"]="1" ["5.4.6"]="1" ["5.5.10"]="1" ["5.6.10"]="1" ["5.7.19"]="2")
# Base repository URL
repo_url="https://github.com/shopware5/shopware.git"
# Destination base directory
base_dir="shops"
# Iterate over the versions array
for version in "${!versions[@]}"; do
# Define the destination directory for the current version
dest_dir="$base_dir/$version"
# Create the destination directory if it doesn't exist
rm -rf "$dest_dir"
mkdir -p "$dest_dir"
# Determine which Composer version to use based on the version
composer_version="${versions[$version]}"
# Attempt to download and extract the archive directly without .git metadata
if git archive --remote="$repo_url" --format=tar "v$version" | tar -x -C "$dest_dir"; then
echo "Successfully extracted version $version into $dest_dir without .git metadata"
else
echo "Fallback to cloning due to remote archive extraction failure."
# Clone the specific tag into the destination directory, then remove the .git directory
if git clone --branch "v$version" --depth 1 "$repo_url" "$dest_dir"; then
rm -rf "$dest_dir/.git"
echo "Successfully cloned and cleaned version $version into $dest_dir"
else
echo "Failed to clone version $version. Skipping..."
continue
fi
fi
echo "Successfully cloned version $version into $dest_dir"
# Navigate into the directory and run Composer install using a Docker container with PHP 7.4
echo "Running Composer install for version $version..."
docker run --rm -v "$(pwd)/$dest_dir":/app composer:$composer_version composer install --no-dev --ignore-platform-reqs
done
# Change ownership of the copied files to the current user
sudo chown -R $(whoami):$(whoami) "./shops"
echo "All specified versions processed."