homeserver/.gitlab-ci.yml

106 lines
2.8 KiB
YAML

stages:
- lint
- ping-test
- deploy-test
- ping-prod
- deploy-prod
ansible-lint:
image: quotengrote/gitlab-ci-ansible:latest
stage: lint
before_script:
- chmod 0755 /builds/mg/ansible
script:
- ansible-lint .
interruptible: true
allow_failure: true
rules:
- if: $CI_MERGE_REQUEST_ID
tags:
- ansible
markdown-lint:
stage: lint
image: pipelinecomponents/markdownlint:latest
script:
- mdl --style all --warnings --rules ~MD022,~MD013 .
interruptible: true
allow_failure: true
rules:
- if: $CI_MERGE_REQUEST_ID
tags:
- ansible
ping-test:
image: quotengrote/gitlab-ci-ansible:latest
stage: ping-test
interruptible: true
before_script:
- chmod 0755 /builds/mg/ansible
- echo "$id_rsa_ansible_user" > /builds/mg/ansible/id_rsa_ansible_user
- chmod 0400 /builds/mg/ansible/id_rsa_ansible_user
script:
- ansible -i inventory --limit test --vault-password-file $ansible_vault_pass all -m ping
after_script:
- rm /builds/mg/ansible/id_rsa_ansible_user
rules:
- if: $CI_MERGE_REQUEST_ID
tags:
- ansible
ansible-deploy-test:
image: quotengrote/gitlab-ci-ansible:latest
stage: deploy-test
interruptible: false
before_script:
- chmod 0755 /builds/mg/ansible
- echo "$id_rsa_ansible_user" > /builds/mg/ansible/id_rsa_ansible_user
- chmod 0400 /builds/mg/ansible/id_rsa_ansible_user
script:
- ansible-playbook playbooks/base/0_master.yml playbooks/service/* -i inventory --limit test --vault-password-file $ansible_vault_pass
after_script:
- rm /builds/mg/ansible/id_rsa_ansible_user
rules:
- if: $CI_MERGE_REQUEST_ID
tags:
- ansible
ping-prod:
image: quotengrote/gitlab-ci-ansible:latest
stage: ping-prod
interruptible: true
before_script:
- chmod 0755 /builds/mg/ansible
- echo "$id_rsa_ansible_user" > /builds/mg/ansible/id_rsa_ansible_user
- chmod 0400 /builds/mg/ansible/id_rsa_ansible_user
script:
- ansible -i inventory --limit production --vault-password-file $ansible_vault_pass all -m ping
after_script:
- rm /builds/mg/ansible/id_rsa_ansible_user
rules:
- if: $CI_COMMIT_BRANCH == 'master'
tags:
- ansible
ansible-deploy-prod:
image: quotengrote/gitlab-ci-ansible:latest
stage: deploy-prod
interruptible: false
before_script:
- chmod 0755 /builds/mg/ansible
- echo "$id_rsa_ansible_user" > /builds/mg/ansible/id_rsa_ansible_user
- chmod 0400 /builds/mg/ansible/id_rsa_ansible_user
script:
- ansible-playbook playbooks/base/0_master.yml playbooks/service/* -i inventory --limit production --vault-password-file $ansible_vault_pass
after_script:
- rm /builds/mg/ansible/id_rsa_ansible_user
rules:
- if: $CI_COMMIT_BRANCH == 'master'
tags:
- ansible
# GitLab-CI-Vars
# $ansible_vault_pass - Type: File
# $id_rsa_ansible_user - Type: Variable