-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
61 lines (53 loc) · 1.77 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
image: "registry.gitlab.com/swiftyteam/swifty-infrastructure/gitlab-runner:latest"
variables:
ANSIBLE_HOST_KEY_CHECKING: "False"
before_script:
- eval $(ssh-agent -s)
- echo "$REPO_ACCESS_KEY" | tr -d '\r' | ssh-add - > /dev/null
stages:
- infrastructure
- deploy
- cleanup
- build
.infrastructure:
stage: infrastructure
artifacts:
name: "terraform-${CI_COMMIT_SHA:0:8}"
paths:
- terraform.tf
- terraform.tfstate
- output.json
script:
- . /home/.env/bin/activate
- pip install -r requirements.txt
- python tfgen.py ${CI_COMMIT_SHA:0:8}
- terraform init
- terraform apply -auto-approve
- terraform output -json > output.json
- chmod +x ansible_inventory.py
.deploy:
stage: deploy
script:
- git clone https://$INFRA_ACCESS_TOKEN_USERNAME:[email protected]/swiftyteam/swifty-infrastructure.git $CI_JOB_NAME
- ansible-playbook -i ansible_inventory.py $CI_JOB_NAME/swifty-ansible/swifty.yml --extra-vars="$(python ansible_inventory.py -e)"
- rm -rf $CI_JOB_NAME
#ui-show-url:
# stage: test
# script:
# - git clone [email protected]:swiftyteam/swifty-infrastructure.git $CI_JOB_NAME
# - ansible-playbook -i ansible_inventory.py $CI_JOB_NAME/swifty-full-aws/swifty.yml --skip-tags="tinc,swy-gw,swy-mw,swy-worker,swy-ui"
# - rm -rf $CI_JOB_NAME
# - sleep 600
.cleanup:
stage: cleanup
script:
- terraform destroy -auto-approve
build:
stage: build
only:
- master
#tags:
# - swifty
script:
- git clone https://$INFRA_ACCESS_TOKEN_USERNAME:[email protected]/swiftyteam/swifty-infrastructure.git $CI_JOB_NAME
- ansible-playbook -i gitlab-runner.ci.swifty.cloud, $CI_JOB_NAME/swifty-build/tasks/main.yml --extra-vars="basedir=/home/fedora/swifty"