59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
stages:
|
|
- build
|
|
- deploy
|
|
- test
|
|
|
|
develop-build-job:
|
|
stage: build
|
|
tags:
|
|
- node
|
|
script:
|
|
- echo "Install dependencies..."
|
|
- npm install
|
|
- npm run build
|
|
only:
|
|
- develop
|
|
|
|
master-build-job:
|
|
stage: build
|
|
tags:
|
|
- node
|
|
script:
|
|
- echo "Install dependencies..."
|
|
- npm install
|
|
- npm run build --prod
|
|
artifacts:
|
|
paths:
|
|
- dist/
|
|
only:
|
|
- master
|
|
|
|
deploy-job:
|
|
stage: deploy
|
|
tags:
|
|
- node
|
|
when: manual
|
|
environment:
|
|
name: Production
|
|
url: "$Live_Server_IP"
|
|
before_script:
|
|
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y)'
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
|
|
script:
|
|
- tar zcf ../inkletblot-com.tar.gz ./dist
|
|
- scp -P "$Live_Server_Access_Port" -o StrictHostKeyChecking=no ../inkletblot-com.tar.gz "$Live_Server_User"@"$Live_Server_IP":/var/www/html
|
|
- ssh -p "$Live_Server_Access_Port" "$Live_Server_User"@"$Live_Server_IP" "rm -Rf /var/www/html/inkletblot-com_old && mv /var/www/html/inkletblot-com /var/www/html/inkletblot-com_old && mkdir /var/www/html/inkletblot-com_build && mkdir /var/www/html/inkletblot-com && tar zxf /var/www/html/inkletblot-com.tar.gz -C /var/www/html/inkletblot-com_build && mv /var/www/html/inkletblot-com_build/dist/inkletblot-com/* /var/www/html/inkletblot-com && rm -Rf /var/www/html/inkletblot-com_build && chmod -R 755 /var/www/html/inkletblot-com && exit"
|
|
only:
|
|
- master
|
|
|
|
test:
|
|
stage: test
|
|
script:
|
|
- echo "I don't care about standard merges into dev as a build has to happen for a merge into master, I don't think there is a way to specify that so I need this here."
|
|
only:
|
|
- merge_requests
|