-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
62 lines (56 loc) · 1.97 KB
/
.gitlab-ci.yml
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
variables:
DOCKER_TLS_CERTDIR: "/certs"
stages:
- test
- build
- deploy
# Test the running bot using the Python test file provided.
test-bot:
stage: test
image: python:3.8
script:
- apt-get update -qy
- pip install awscli
- aws s3 cp s3://movie-vote-bot-bucket/config.yaml .
- pip install -r requirements.txt
- export bot_environment=ci-tests
- python bot.py &
- python bot_test.py --channel $CHANNEL_ID --run all $TARGET_BOT_ID $TESTER_BOT_TOKEN
# Build an image, only on the master branch, and push to AWS Elastic Container Registry (ECR)
build-image:
stage: build
image: docker:19.03.12
services:
- docker:19.03.12-dind
script:
- apk update
- apk add python3 py-pip
- pip install awscli
- docker build -t discord-movie-bot:latest -f .docker/bot.yml .
- docker tag discord-movie-bot:latest $AWS_ECR_REPO/discord-movie-bot:latest
- $(aws ecr get-login --no-include-email --region eu-west-2)
- docker push $AWS_ECR_REPO/discord-movie-bot:latest
only:
- master
fargate-deployment:
stage: deploy
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest
variables:
CI_AWS_ECS_CLUSTER: discord_movie_bot_fg
CI_AWS_ECS_SERVICE: bot_service
CI_AWS_ECS_TASK_DEFINITION: discord_movie_bot_task
REGION: eu-west-2
script:
- TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition "${CI_AWS_ECS_TASK_DEFINITION}" --region "${REGION}")
- NEW_CONTAINER_DEFINTIION=$(echo ${TASK_DEFINITION} | jq '.taskDefinition.containerDefinitions[0]')
- aws ecs register-task-definition
--family "${CI_AWS_ECS_TASK_DEFINITION}"
--requires-compatibilities "FARGATE"
--region "${REGION}"
--cli-input-json file://.tf/policies/task-def.json
- aws ecs update-service --cluster "${CI_AWS_ECS_CLUSTER}"
--service "${CI_AWS_ECS_SERVICE}"
--task-definition "${CI_AWS_ECS_TASK_DEFINITION}"
--region "${REGION}"
only:
- master