-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·77 lines (63 loc) · 1.92 KB
/
entrypoint.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
# Set variables
GENERATE_ZIP=false
NODE_VERSION="v22.10.0"
BUILD_PATH="./build"
WORKING_DIRECTORY="$GITHUB_WORKSPACE"
ZIP_DIRECTORY="build"
echo "Are we building the ZIP? $1"
echo "Requested Node $2"
# Set options based on user input
if [ -z "$1" ]; then
GENERATE_ZIP="$1"
fi
if [ -n "$2" ]; then
NODE_VERSION="$2"
fi
# If not configured defaults to repository name
if [ -z "$PLUGIN_SLUG" ]; then
PLUGIN_SLUG=${GITHUB_REPOSITORY#*/}
fi
# Set GitHub "path" output
DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG"
echo "::set-output name=path::$DEST_PATH"
# Install dependencies
cd "$WORKING_DIRECTORY" || exit
# Install and build PHP dependencies
if [ -f "composer.json" ]; then
echo "Installing PHP dependencies..."
if [ -n "$RUNNER_DEBUG" ]; then
echo "Debug logging is enabled. Running Composer with -vvv."
composer install -vvv --no-dev --ignore-platform-reqs --no-cache || exit "$?"
else
composer install --no-dev --ignore-platform-reqs --no-cache || exit "$?"
fi
fi
# Install and build assets
if [ -f "package.json" ]; then
echo "Installing asset dependencies..."
echo "Using Node $NODE_VERSION"
. /usr/local/nvm/nvm.sh
nvm install $NODE_VERSION
nvm use $NODE_VERSION
npm install
echo "Running asset build..."
npm run prod || exit "$?"
fi
echo "Generating build directory..."
rm -rf "$BUILD_PATH"
mkdir -p "$DEST_PATH"
if [ -r "${WORKING_DIRECTORY}/.distignore" ]; then
rsync -rc --exclude-from="$WORKING_DIRECTORY/.distignore" "$WORKING_DIRECTORY/" "$DEST_PATH/" --delete --delete-excluded
else
rsync -rc "$WORKING_DIRECTORY/" "$DEST_PATH/" --delete
fi
if ! $GENERATE_ZIP; then
echo "Generating zip file..."
cd "$BUILD_PATH" || exit
zip -r "${PLUGIN_SLUG}.zip" "$PLUGIN_SLUG/"
# Set GitHub "zip_path" output
echo "::set-output name=zip_path::${ZIP_DIRECTORY}/${PLUGIN_SLUG}.zip"
echo "Zip file generated!"
fi
echo "Build done!"