forked from lotusnoir/ansible-apps_gobetween
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
83 lines (73 loc) · 2.16 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
---
stages:
- lint
- test
- changes
- push
variables:
GITHUB_USER: lotusnoir
##################################################
# LINT
##################################################
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
######################################################
# GENERATE CHANGELOG FILE
######################################################
changelog:
stage: changes
image: node:19
needs:
- yamllint
- ansible-lint
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 [email protected]:${GITHUB_USER}/ansible-apps_gobetween.git /tmp/ansible-apps_gobetween
- find /tmp/ansible-apps_gobetween -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf "{}" +;
- rm -rf .git
- cp -r . /tmp/ansible-apps_gobetween/
- cd /tmp/ansible-apps_gobetween
- git add -A
- git commit -m "${COMMENT}" || echo "No changes, nothing to commit!"
- git push --follow-tags