CI : refactor
This commit is contained in:
parent
22407bd9b2
commit
f9796be7f2
1 changed files with 34 additions and 32 deletions
|
|
@ -5,15 +5,16 @@ stages:
|
||||||
variables:
|
variables:
|
||||||
COMPOSER_ALLOW_SUPERUSER: '1'
|
COMPOSER_ALLOW_SUPERUSER: '1'
|
||||||
|
|
||||||
build_prod:
|
# PREPROD
|
||||||
|
build_preprod:
|
||||||
stage: build
|
stage: build
|
||||||
only:
|
only:
|
||||||
- prod
|
- preprod
|
||||||
image: composer:2
|
image: composer:2
|
||||||
script:
|
script:
|
||||||
- apk add --no-cache nodejs npm
|
- apk add --no-cache nodejs npm
|
||||||
- npm install
|
- npm install
|
||||||
- npm run build
|
- npm run build:preprod
|
||||||
- cd dist
|
- cd dist
|
||||||
- composer install --no-dev --optimize-autoloader --ignore-platform-req=ext-gd
|
- composer install --no-dev --optimize-autoloader --ignore-platform-req=ext-gd
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
@ -25,15 +26,42 @@ build_prod:
|
||||||
paths:
|
paths:
|
||||||
- node_modules/
|
- node_modules/
|
||||||
|
|
||||||
build_preprod:
|
deploy_preprod:
|
||||||
stage: build
|
stage: deploy
|
||||||
|
image: node:latest
|
||||||
only:
|
only:
|
||||||
- preprod
|
- preprod
|
||||||
|
before_script:
|
||||||
|
- apt-get update -qq && apt-get install -y rsync sshpass
|
||||||
|
script:
|
||||||
|
- cd dist
|
||||||
|
- |
|
||||||
|
rsync_deploy() {
|
||||||
|
local src=$1
|
||||||
|
local dst=$2
|
||||||
|
local exclude=$3
|
||||||
|
cmd="sshpass -p \"$PASSWORD\" rsync -az --delete -O"
|
||||||
|
[[ -n $exclude ]] && cmd="$cmd $exclude"
|
||||||
|
cmd="$cmd -e 'ssh -p 2244 -o StrictHostKeyChecking=no' $src $USERNAME@$HOST:$dst"
|
||||||
|
echo "$cmd"
|
||||||
|
eval $cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
rsync_deploy site/ "$PREPROD_PATH/site/" "--exclude 'accounts/' --exclude 'cache/' --exclude 'sessions/'"
|
||||||
|
rsync_deploy vendor/ "$PREPROD_PATH/vendor/"
|
||||||
|
rsync_deploy kirby/ "$PREPROD_PATH/kirby/"
|
||||||
|
rsync_deploy assets/ "$PREPROD_PATH/assets/" "--exclude 'tiles/'"
|
||||||
|
|
||||||
|
# PROD
|
||||||
|
build_prod:
|
||||||
|
stage: build
|
||||||
|
only:
|
||||||
|
- prod
|
||||||
image: composer:2
|
image: composer:2
|
||||||
script:
|
script:
|
||||||
- apk add --no-cache nodejs npm
|
- apk add --no-cache nodejs npm
|
||||||
- npm install
|
- npm install
|
||||||
- npm run build:preprod
|
- npm run build
|
||||||
- cd dist
|
- cd dist
|
||||||
- composer install --no-dev --optimize-autoloader --ignore-platform-req=ext-gd
|
- composer install --no-dev --optimize-autoloader --ignore-platform-req=ext-gd
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
@ -70,29 +98,3 @@ deploy_prod:
|
||||||
rsync_deploy vendor/ "$PROD_PATH/vendor/"
|
rsync_deploy vendor/ "$PROD_PATH/vendor/"
|
||||||
rsync_deploy kirby/ "$PROD_PATH/kirby/"
|
rsync_deploy kirby/ "$PROD_PATH/kirby/"
|
||||||
rsync_deploy assets/ "$PROD_PATH/assets/" "--exclude 'tiles/'"
|
rsync_deploy assets/ "$PROD_PATH/assets/" "--exclude 'tiles/'"
|
||||||
|
|
||||||
deploy_preprod:
|
|
||||||
stage: deploy
|
|
||||||
image: node:latest
|
|
||||||
only:
|
|
||||||
- preprod
|
|
||||||
before_script:
|
|
||||||
- apt-get update -qq && apt-get install -y rsync sshpass
|
|
||||||
script:
|
|
||||||
- cd dist
|
|
||||||
- |
|
|
||||||
rsync_deploy() {
|
|
||||||
local src=$1
|
|
||||||
local dst=$2
|
|
||||||
local exclude=$3
|
|
||||||
cmd="sshpass -p \"$PASSWORD\" rsync -az --delete -O"
|
|
||||||
[[ -n $exclude ]] && cmd="$cmd $exclude"
|
|
||||||
cmd="$cmd -e 'ssh -p 2244 -o StrictHostKeyChecking=no' $src $USERNAME@$HOST:$dst"
|
|
||||||
echo "$cmd"
|
|
||||||
eval $cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
rsync_deploy site/ "$PREPROD_PATH/site/" "--exclude 'accounts/' --exclude 'cache/' --exclude 'sessions/'"
|
|
||||||
rsync_deploy vendor/ "$PREPROD_PATH/vendor/"
|
|
||||||
rsync_deploy kirby/ "$PREPROD_PATH/kirby/"
|
|
||||||
rsync_deploy assets/ "$PREPROD_PATH/assets/" "--exclude 'tiles/'"
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue