-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
55 lines (50 loc) · 1.66 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
---
stages:
- changes
- push
variables:
GITHUB_USER: lotusnoir
ANSIBLE_REMOTE_TMP: /tmp
PY_COLORS: 1
######################################################
# GENERATE CHANGELOG FILE
######################################################
changelog:
stage: changes
image: node:19
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-provi_proxmox_kvm.git /tmp/ansible-provi_proxmox_kvm
- find /tmp/ansible-provi_proxmox_kvm -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf "{}" +;
- rm -rf .git
- cp -r . /tmp/ansible-provi_proxmox_kvm/
- cd /tmp/ansible-provi_proxmox_kvm
- git add -A
- git commit -m "${COMMENT}" || echo "No changes, nothing to commit!"
- git push --follow-tags