-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
137 lines (128 loc) · 3.52 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
stages:
- molecule
- changes
- push
variables:
GITHUB_USER: lotusnoir
ANSIBLE_REMOTE_TMP: /tmp
PY_COLORS: 1
##################################################
# LINT # we remove it as managed by pre-commit instead
##################################################
#yamllint:
# stage: lint
# image: sdesbure/yamllint
# before_script:
# - yamllint --version
# script:
# - yamllint .
#
#ansible-lint:
# stage: lint
# image: lotusnoir/ansible_play
# script:
# - ansible-lint .
##################################################
# TEST / SECU
##################################################
#include:
# - template: Security/Secret-Detection.gitlab-ci.yml
######################################################
# RUN MOLECULE FOR EACH DISTRIB
######################################################
molecule_ubuntu22:
stage: molecule
image: lotusnoir/molecule_play
services:
- docker:dind
script:
- MOLECULE_DISTRIB=ubuntu22 molecule test
molecule_ubuntu20:
stage: molecule
image: lotusnoir/molecule_play
services:
- docker:dind
variables:
MOLECULE_DOCKER_COMMAND: "--cap-add NET_ADMIN"
script:
- MOLECULE_DISTRIB=ubuntu20 molecule test
molecule_ubuntu18:
stage: molecule
image: lotusnoir/molecule_play
services:
- docker:dind
variables:
MOLECULE_DOCKER_COMMAND: "--cap-add NET_ADMIN"
script:
- MOLECULE_DISTRIB=ubuntu18 molecule test
molecule_debian10:
stage: molecule
image: lotusnoir/molecule_play
services:
- docker:dind
script:
- MOLECULE_DISTRIB=debian10 molecule test
molecule_debian11:
stage: molecule
image: lotusnoir/molecule_play
services:
- docker:dind
script:
- MOLECULE_DISTRIB=debian11 molecule test
molecule_debian12:
stage: molecule
image: lotusnoir/molecule_play
services:
- docker:dind
script:
- MOLECULE_DISTRIB=debian12 molecule test
######################################################
# GENERATE CHANGELOG FILE
######################################################
changelog:
stage: changes
image: node:19
needs:
- molecule_ubuntu22
- molecule_ubuntu20
- molecule_ubuntu18
- molecule_debian10
- molecule_debian11
- molecule_debian12
artifacts:
paths:
- CHANGELOG.md
expire_in: 1 day
before_script:
- npm install -g auto-changelog
script:
- auto-changelog -t keepachangelog --sort-commits date-desc --hide-empty-releases --hide-credit -l 10 -b 10
##################################################
# PUSH CODE WHEN ALL TEST OK
##################################################
push_src_on_github:
stage: push
image: alpine:latest
needs:
- changelog
before_script:
- apk add git openssh-client
- eval $(ssh-agent -s)
- echo "${GITHUB_USER_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tUser ansible\n\tStrictHostKeyChecking no\n\tForwardAgent yes\n\n" > ~/.ssh/config
- git config --global user.email "${GITHUB_USER_EMAIL}"
- git config --global user.name "${GITHUB_USER}"
- git config --global init.defaultBranch main
- COMMENT=$(git log -1 --pretty=%B | head -1)
script:
- git clone git@github.com:${GITHUB_USER}/ansible-apps_smtp.git /tmp/ansible-apps_smtp
- find /tmp/ansible-apps_smtp -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf "{}" +;
- rm -rf .git
- cp -r . /tmp/ansible-apps_smtp/
- cd /tmp/ansible-apps_smtp
- git add -A
- git commit -m "${COMMENT}" || echo "No changes, nothing to commit!"
- git push --follow-tags