-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate-multidev.sh
More file actions
executable file
·72 lines (56 loc) · 2.53 KB
/
create-multidev.sh
File metadata and controls
executable file
·72 lines (56 loc) · 2.53 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -euo pipefail
MULTIDEV_NAME="$1"
TERMINUS_SITE="$2"
GITHUB_ENV_FILE="${3:-${GITHUB_ENV:-}}"
GIT_REF="${4:-dev-1.0.x}"
# Limit multidev name to 11 characters
MULTIDEV="${MULTIDEV_NAME:0:11}"
# Check if multidev with the same name already exists, if so delete it
if terminus multidev:list "$TERMINUS_SITE" --format=list | grep -q "^$MULTIDEV$"; then
terminus multidev:delete "$TERMINUS_SITE.$MULTIDEV" --delete-branch --yes
fi
# Create new multidev from dev environment
terminus multidev:create "$TERMINUS_SITE.dev" "$MULTIDEV"
# Get git URL
echo "Getting Pantheon git URL..."
GIT_URL=$(terminus connection:info $TERMINUS_SITE.$MULTIDEV --field=git_url)
echo "Git URL: $GIT_URL"
# Clone the Pantheon site repository
echo "Cloning repository..."
GIT_SSH_COMMAND="ssh -v -o StrictHostKeyChecking=no" git clone "$GIT_URL" pantheon-site
cd pantheon-site
# Checkout the multidev branch that was created by terminus
echo "Checking out branch $MULTIDEV..."
git checkout "$MULTIDEV"
# Add pantheon_content_publisher module via composer
composer config repositories.pantheon_content_publisher '{"type": "vcs", "url": "git@github.com:pantheon-systems/pantheon-content-publisher-drupal.git", "canonical": false}'
composer require drupal/pantheon_content_publisher:"${GIT_REF}"
# Show where the module was installed for diagnostics.
echo "Module installed at:"
find . -path '*/pantheon_content_publisher/pantheon_content_publisher.info.yml' -not -path './vendor/*' | head -1
# Remove git directories from submodules.
# Detect the module path dynamically (nested docroot vs flat).
if [ -d web/modules/contrib/pantheon_content_publisher/.git ]; then
MODULE_INSTALL_PATH="web/modules/contrib/pantheon_content_publisher"
elif [ -d modules/contrib/pantheon_content_publisher/.git ]; then
MODULE_INSTALL_PATH="modules/contrib/pantheon_content_publisher"
fi
if [ -n "${MODULE_INSTALL_PATH:-}" ]; then
echo "Removing .git from $MODULE_INSTALL_PATH"
rm -rf "$MODULE_INSTALL_PATH/.git/"
fi
rm -rf vendor/*/.git/
# Commit and push changes
git add .
git commit -m 'Add pantheon_content_publisher module'
git push --set-upstream origin "$MULTIDEV"
cd ..
# Wait for Pantheon to finish building and deploying the code
echo "Waiting for Pantheon build to complete..."
terminus workflow:wait $TERMINUS_SITE.$MULTIDEV --max=300
# Enable the module
echo "Enabling pantheon_content_publisher module..."
terminus drush $TERMINUS_SITE.$MULTIDEV -- pm:enable pantheon_content_publisher -y
# Save the multidev name for later steps
echo "MULTIDEV_ENV=$MULTIDEV" >> "$GITHUB_ENV_FILE"