You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
2.2 KiB

# This file is a template, and might need editing before it works on your project.
# Official docker image.
#image: docker:latest
#services:
# - docker:dind
variables:
CHANNEL: "skillbox"
SERVER_URL: "lms.test.spicycms.com"
DOMAIN: "$CI_BUILD_REF_SLUG.$SERVER_URL"
SLACK_MSG: "Check new website <http://$DOMAIN>"
#SLACK_PAYLOAD: 'payload={\"channel\":\"#'${CHANNEL}'\",\"username\":\"'${SERVER_URL}'\",\"text\":\"'${SLACK_MSG}'\",\"icon_emoji\":\":ghost:\"}'
SLACK_URL: "https://hooks.slack.com/services/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"
types:
- build
- test
build_app:
type: build
script:
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY
- docker build --no-cache --rm --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG" --build-arg SSH_PRIVATE_KEY="$SSH_PRIVATE_KEY" --build-arg SPICYCODE_LOGIN="$SPICYCODE_LOGIN" --build-arg SPICYCODE_PASS="$SPICYCODE_PASS" .
#- docker run --rm --add-host dockerhost:`/sbin/ip route|awk '/default/ { print $3}'` "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG" python manage.py test
- docker push "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG"
test_app:
type: test
script:
#- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY
#- docker pull "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG"
- if [[ $(docker ps -a) == *$DOMAIN* ]] ; then docker stop $DOMAIN ; fi
- if [[ $(docker ps -a) == *$DOMAIN* ]] ; then docker rm $DOMAIN; fi
- "SLACK_PAYLOAD='payload={\"channel\":\"#'${CHANNEL}'\",\"username\":\"'${SERVER_URL}'\",\"text\":\"'${SLACK_MSG}'\",\"icon_emoji\":\":ghost:\"}'"
- docker run -d --expose=80 -e VIRTUAL_HOST=$DOMAIN --name=$DOMAIN -e DB_NAME=$DB_NAME -e PG_PORT_5432_TCP_ADDR=$DB_HOST -e PG_PORT_5432_TCP_PORT=$DB_PORT -e PG_ENV_POSTGRES_USER=$DB_TEST_USER -e PG_ENV_POSTGRES_PASSWORD=$DB_TEST_PASS "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG"
- curl -I $DOMAIN 2>/dev/null | head -n 1 | cut -d$' ' -f2
- echo ${SLACK_PAYLOAD}
- curl -X POST -d ${SLACK_PAYLOAD} $SLACK_URL
- SLACK_MSG="REVIEW app is started on https://$DOMAIN/"
- SLACK_PAYLOAD="payload={\"text\":\"$SLACK_MSG\",\"username\":\"gitlab-ci\"}"
- curl -X POST -d "$SLACK_PAYLOAD" $SLACK_URL
dependencies:
- build_app