-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
40 lines (37 loc) · 1.18 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
stages:
- build
- deploy
variables:
IMAGE_NAME: ${CI_REGISTRY_IMAGE}:grand-tetras-jura-${CI_COMMIT_REF_NAME}
build_app:
stage: build
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build --pull --target production -t $IMAGE_NAME -t ${CI_REGISTRY_IMAGE}:latest ./
- docker push $IMAGE_NAME
- docker push ${CI_REGISTRY_IMAGE}:latest
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_BRANCH != "main"'
when: manual
tags:
- NSCICDDOCKER
deploy:
stage: deploy
image: registry.gitlab.com/natural-solutions/ns-ansible-infrastructure
id_tokens:
NATURALIENS_ID_TOKEN:
aud: https://vault.naturaliens.cloud
script:
- cd /home/ansible
- export VAULT_TOKEN="$(vault write -field=token auth/jwt/login role=gitlab-runner-grand-tetras-jura jwt=$NATURALIENS_ID_TOKEN)"
- ansible-playbook -i inventory.py playbooks/grand-tetras-jura.yml
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_BRANCH != "main"'
when: manual
variables:
GIT_STRATEGY: none
INVENTORY_PATH: inventories/ns/projects/grand-tetras-jura
tags:
- pve03-gitlab-runner01