-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitlab-ci.yml
46 lines (44 loc) · 1.65 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
stages:
- Test
- Deploy
.Test Role: &Test_Role
image: sparknsh/ansible:${OS}
stage: Test
before_script:
- cp -R ${CI_PROJECT_DIR}/* /etc/ansible/roles/role_under_test/.
script:
- ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check
- export ANSIBLE_FORCE_COLOR=1 && ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
- idempotence=$(mktemp)
- export ANSIBLE_FORCE_COLOR=0 && ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a $idempotence
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
tags:
- gce
GitHub:
image: rebelmediausa/debian
stage: Deploy
before_script:
- "VERSION=$(grep 'Version:' README.md | cut -d ' ' -f3 | awk '{print substr($0,1,5)}')"
- git config --global user.email "${GITEMAIL}"
- git config --global user.name "${GITUSER}"
- git config --global push.followTags true
- git clone [email protected]:${GITUSER}/${CI_PROJECT_NAME}.git WORKING
- git clone [email protected]:${GITUSER}/${CI_PROJECT_NAME}.git DEPLOY
- cd ${CI_PROJECT_DIR}/WORKING
- git checkout ${CI_COMMIT_SHA:0:8}
- rm -Rf ${CI_PROJECT_DIR}/WORKING/.git
- rsync -avzI ${CI_PROJECT_DIR}/WORKING/ ${CI_PROJECT_DIR}/DEPLOY/
- cd ${CI_PROJECT_DIR}/DEPLOY
script:
- git add --all
- git commit -m "$(TZ=":UTC" date +"%Y-%m-%d %H:%M:%S")"
- if [ -z "$(git show-ref --tags v${VERSION})" ]; then git tag -a v${VERSION} -m "Version ${VERSION}"; fi
- git push origin master
only:
- master
tags:
- private