-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.cpanel.yml
More file actions
60 lines (53 loc) · 1.95 KB
/
.cpanel.yml
File metadata and controls
60 lines (53 loc) · 1.95 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
---
deployment:
tasks:
# If .deploy.conf doesn't exist, create it from .deploy.example.conf
- |
if [ ! -f .deploy.conf ]
then
cp .deploy.example.conf .deploy.conf
exit
else
source .deploy.conf
fi
# Set variables
- export DEPLOY_LOG="$DEPLOY_PATH/.deploy.log"
- export DEPLOY_LIST="$DEPLOY_PATH/.deployed-files.txt"
# Create deployment path if it doesn't exist
- if [ ! -d "$DEPLOY_PATH" ]; then mkdir -p "$DEPLOY_PATH"; fi
# Start deployment
- echo "=== Deployment started" > "$DEPLOY_LOG"
# Remove old files and empty directories
- |
if [ -f "$DEPLOY_LIST" ]
then
echo "=== Removing old files" >> "$DEPLOY_LOG"
tac "$DEPLOY_LIST" | while read file; do
if [ -d "$DEPLOY_PATH/$file" ] && [ ! "$(ls -A "$DEPLOY_PATH/$file")" ]
then
echo "Removing empty directory: $file" >> "$DEPLOY_LOG"
rmdir "$DEPLOY_PATH/$file"
elif [ -f "$DEPLOY_PATH/$file" ]
then
echo "Removing file: $file" >> "$DEPLOY_LOG"
rm "$DEPLOY_PATH/$file"
fi
done
fi
# Copy new files
- |
echo "=== Copying new files" >> "$DEPLOY_LOG"
find -mindepth 1 \
! -path "*/.git*" \
! -name ".cpanel.yml" \
! -name ".deploy.conf" \
! -name ".deploy.example.conf" \
-exec echo "{}" >> "$DEPLOY_LOG" \;\
-exec cp -RTpu "{}" "$DEPLOY_PATH/{}" \;\
-fprint ""$DEPLOY_LIST""
# Switch working directory
- cd $DEPLOY_PATH
# Setup composer
- /opt/cpanel/ea-php84/root/usr/bin/php -v &>> "$DEPLOY_LOG"
- if [ ! -f composer.phar ]; then wget -O - https://getcomposer.org/installer | /opt/cpanel/ea-php84/root/usr/bin/php &>> "$DEPLOY_LOG"; fi
- /opt/cpanel/ea-php84/root/usr/bin/php composer.phar install --no-interaction --ignore-platform-reqs --no-dev &>> "$DEPLOY_LOG"