Skip to content

Commit 196930a

Browse files
committed
add deploy commands
1 parent c6d7cc5 commit 196930a

14 files changed

Lines changed: 161 additions & 8 deletions

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.insertSpaces": false
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function _assert_terminus_vars() {
2+
if [ -z "$TERMINUS_ENV" ]; then
3+
echo "TERMINUS_ENV environment variable is not set."
4+
exit 1
5+
fi
6+
7+
if [ -z "$TERMINUS_SITE" ]; then
8+
echo "TERMINUS_SITE environment variable is not set."
9+
exit 1
10+
fi
11+
12+
if [ -z "$DRUSH_TASK" ]; then
13+
echo "DRUSH_TASK environment variable is not set."
14+
exit 1
15+
fi
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function _pantheon_deploy() {
2+
_assert_terminus_vars
3+
if [ -z "$deploy_args" ]; then
4+
echo "Error: deploy_args is not set." >&2
5+
exit 1
6+
fi
7+
terminus drush -- state-set system.maintenance_mode TRUE
8+
terminus env:clear-cache
9+
terminus env:deploy $deploy_args
10+
terminus drush -- cache-rebuild
11+
terminus drush -- $DRUSH_TASK
12+
sleep 60
13+
terminus env:clear-cache
14+
}

local/etc/uceap.d/_sftp_code.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function _sftp_code() {
2+
SFTP_PORT=`terminus connection:info --field=sftp_port`
3+
SFTP_USER=`terminus connection:info --field=sftp_username`
4+
SFTP_HOST=`terminus connection:info --field=sftp_host`
5+
6+
terminus connection:set sftp -y
7+
rsync -e "ssh -p $SFTP_PORT -o StrictHostKeyChecking=no" -rv --checksum --delete --exclude=web/sites/default/files ./ $SFTP_USER@$SFTP_HOST:code/
8+
}

local/etc/uceap.d/deploy-to-dev.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function deploy_to_dev() {
2+
export TERMINUS_ENV="dev"
3+
4+
_assert_terminus_vars
5+
_sftp_code
6+
terminus env:commit --force -y
7+
8+
terminus drush -- $DRUSH_TASK
9+
}
10+
11+
_deploy_to_dev_desc='deploys the local code to the Pantheon DEV environment'
12+
_deploy_to_dev_help='
13+
Deploys the local code to the Pantheon DEV environment.
14+
15+
# Usage
16+
17+
```bash
18+
uceap deploy-to-dev
19+
```
20+
21+
## Description
22+
23+
This command requires the `TERMINUS_SITE` and `DRUSH_TASK` environment variables to be set.
24+
'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function deploy_to_live() {
2+
export TERMINUS_ENV="live"
3+
4+
deploy_args=""
5+
6+
_pantheon_deploy
7+
}
8+
9+
_deploy_to_live_desc='deploys the local code to the Pantheon LIVE environment'
10+
_deploy_to_live_help='
11+
Deploys the local code to the Pantheon LIVE environment.
12+
13+
# Usage
14+
15+
```bash
16+
uceap deploy-to-live
17+
```
18+
19+
## Description
20+
21+
This command requires the `TERMINUS_SITE` and `DRUSH_TASK` environment variables to be set.
22+
'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function deploy_to_multidev() {
2+
_assert_terminus_vars
3+
_sftp_code
4+
5+
terminus drush -- $DRUSH_TASK
6+
}
7+
8+
_deploy_to_multidev_desc='deploys the local code to a Pantheon multidev'
9+
_deploy_to_multidev_help='
10+
Deploys the local code to a Pantheon multidev.
11+
12+
# Usage
13+
14+
```bash
15+
TERMINUS_ENV=pr-1234 uceap deploy-to-multidev
16+
```
17+
18+
## Description
19+
20+
This command requires the `TERMINUS_SITE` and `DRUSH_TASK` environment variables to be set.
21+
22+
It also requires the `TERMINUS_ENV` environment variable to be set.
23+
'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function deploy_to_test() {
2+
export TERMINUS_ENV="test"
3+
4+
deploy_args="$deploy_args --sync-content"
5+
if [ $# -eq 1 ]; then
6+
if [ "$1" = "--no-sync" ]; then
7+
deploy_args=""
8+
else
9+
echo "Error: Unsupported argument $1" >&2
10+
exit 1
11+
fi
12+
fi
13+
14+
_pantheon_deploy
15+
}
16+
17+
_deploy_to_test_desc='deploys the local code to the Pantheon TEST environment'
18+
_deploy_to_test_help='
19+
Deploys the local code to the Pantheon TEST environment.
20+
21+
# Usage
22+
23+
```bash
24+
uceap deploy-to-test
25+
```
26+
27+
## Description
28+
29+
This command requires the `TERMINUS_SITE` and `DRUSH_TASK` environment variables to be set.
30+
'

local/etc/uceap.d/devcontainer_on_create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function devcontainer_on_create() {
6060
fi
6161
}
6262

63-
_devcontainer_on_create_desc='Runs when the devcontainer is created'
63+
_devcontainer_on_create_desc='runs when the devcontainer is created'
6464
_devcontainer_on_create_help='
6565
This command implements the `onCreateCommand` lifecycle event for dev containers.
6666

local/etc/uceap.d/devcontainer_post_create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function devcontainer_post_create() {
3434
fi
3535
}
3636

37-
_devcontainer_post_create_desc='Runs after the devcontainer is created'
37+
_devcontainer_post_create_desc='runs after the devcontainer is created'
3838
_devcontainer_post_create_help='
3939
This command implements the `postCreateCommand` lifecycle event for dev containers.
4040

0 commit comments

Comments
 (0)