Skip to content

Commit

Permalink
Updated to be GitHub Actions ready
Browse files Browse the repository at this point in the history
  • Loading branch information
ntimo committed Jul 11, 2022
1 parent 4054f78 commit 98fb52d
Show file tree
Hide file tree
Showing 24 changed files with 108 additions and 416 deletions.
126 changes: 0 additions & 126 deletions .drone.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keys/*
hostvars.yml
id_ssh_rsa
id_ssh_rsa.pub
group_vars/all/secrets.yml
group_vars/all/secrets*.yml
group_vars/all/localdev_conf.yml
node_modules/*
package-lock.json
Expand Down
18 changes: 18 additions & 0 deletions ci-pip-requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Author: ntimo

# Install requierments
echo "Installing pip requirements"
echo ""
sudo pip3 install hcloud
sudo pip3 install jmespath
sudo pip3 install docker

# Install Ansible
echo ""
echo ""
echo "Installing Ansible Galaxy requirements"
echo ""
ansible-galaxy collection install community.general
ansible-galaxy collection install hetzner.hcloud
12 changes: 0 additions & 12 deletions ci-piprequierments.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci-ssh.sh

This file was deleted.

49 changes: 27 additions & 22 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,44 @@

# Author: ntimo

# Set permissions
chmod +x ./namegenerator.sh
chmod -R 0744 /drone/src/*
SSHKEYFILE=/drone/src/id_ssh_rsa
if [ -f "$SSHKEYFILE" ]; then
chmod 0600 $SSHKEYFILE
fi

echo ""
echo "Writing vault password"
if [ -z "$VAULT_PW" ]; then
echo "VAULT_PW is not set"
exit 1
else
echo "$VAULT_PW" > /drone/src/.vault-pw
echo "$VAULT_PW" > ./.vault-pw
fi

echo ""
echo "Writing vault file"
if [ -z "$VAULT_FILE" ]; then
echo "VAULT_FILE is not set"
exit 1
else
echo $VAULT_FILE | sed 's/ /\n/g' | base64 --decode > ./group_vars/all/secrets.yml
fi

echo ""
echo "Generating CI/CD vars"
# Set global ansible variables
echo "ci_hcloud_server_name: cowintg${DRONE_COMMIT:0:10}" > /drone/src/group_vars/all/drone_servername.yml
echo "ci_drone_commit_hash: ${DRONE_COMMIT:0:10}" > /drone/src/group_vars/all/drone_commit_hash.yml
echo "ci_drone_commit_hash_long: ${DRONE_COMMIT}" > /drone/src/group_vars/all/drone_commit_hash_long.yml
echo "ci_mailcow__mailbox_user_one: $(./namegenerator.sh)" > /drone/src/group_vars/all/drone_mailcow__mailbox_user_one.yml
echo "ci_mailcow__mailbox_user_two: $(./namegenerator.sh)" > /drone/src/group_vars/all/drone_mailcow_mailcow__mailbox_user_two.yml
echo "ci_mailcow__mailbox_user_alias: $(./namegenerator.sh)" > /drone/src/group_vars/all/drone_mailcow__mailbox_user_alias.yml
echo "ci_mailcow__api_key: $(openssl rand -hex 25)" > /drone/src/group_vars/all/drone_mailcow__api_key.yml
echo "ci_mailcow__api_key_read_only: $(openssl rand -hex 25)" > /drone/src/group_vars/all/drone_mailcow__api_key_read_only.yml
echo "ci_mailcow__upload_results: true" > /drone/src/group_vars/all/mailcow__upload_results.yml
echo "ci_hcloud_server_name: cowintg${GITHUB_SHA:0:10}" > ./group_vars/all/drone_servername.yml
echo "ci_drone_commit_hash: ${GITHUB_SHA:0:10}" > ./group_vars/all/drone_commit_hash.yml
echo "ci_drone_commit_hash_long: ${GITHUB_SHA}" > ./group_vars/all/drone_commit_hash_long.yml
echo "ci_mailcow__mailbox_user_one: $(./namegenerator.sh)" > ./group_vars/all/drone_mailcow__mailbox_user_one.yml
echo "ci_mailcow__mailbox_user_two: $(./namegenerator.sh)" > ./group_vars/all/drone_mailcow_mailcow__mailbox_user_two.yml
echo "ci_mailcow__mailbox_user_alias: $(./namegenerator.sh)" > ./group_vars/all/drone_mailcow__mailbox_user_alias.yml
echo "ci_mailcow__api_key: $(openssl rand -hex 25)" > ./group_vars/all/drone_mailcow__api_key.yml
echo "ci_mailcow__api_key_read_only: $(openssl rand -hex 25)" > ./group_vars/all/drone_mailcow__api_key_read_only.yml
echo "ci_mailcow__upload_results: true" > ./group_vars/all/mailcow__upload_results.yml

domains[0]="4884884.xyz"
domains[0]="8448448.xyz"
domains_size=${#domains[@]}
domains_index=$(($RANDOM % $domains_size))

# set env specific ansible variables
echo "ci_mailcow__dns_zone: ${domains[$domains_index]}" > /drone/src/group_vars/all/drone_mailcow__demo_domain.yml
echo "ci_mailcow__git_repo: ${DRONE_GIT_HTTP_URL}" > /drone/src/group_vars/all/drone_mailcow__git_repo.yml
echo "ci_mailcow__git_http_url: ${DRONE_GIT_HTTP_URL:: -4}" > /drone/src/group_vars/all/drone_mailcow__git_http_url.yml
echo "ci_mailcow__git_version: ${DRONE_COMMIT}" > /drone/src/group_vars/all/drone_mailcow__git_version.yml
echo "ci_mailcow__dns_zone: ${domains[$domains_index]}" > ./group_vars/all/drone_mailcow__demo_domain.yml
echo "ci_mailcow__git_repo: https://github.com/${GITHUB_REPOSITORY}.git" > ./group_vars/all/drone_mailcow__git_repo.yml
echo "ci_mailcow__git_http_url: https://github.com/${GITHUB_REPOSITORY}" > ./group_vars/all/drone_mailcow__git_http_url.yml
echo "ci_mailcow__git_version: ${GITHUB_SHA}" > ./group_vars/all/drone_mailcow__git_version.yml
7 changes: 7 additions & 0 deletions fork_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "Running Integration Test project in ${GITHUB_REPOSITORY}"
if [[ "${GITHUB_REPOSITORY}" != "mailcow/mailcow-dockerized" ]]; then
echo "This can't be run in a fork"
exit 1
fi
74 changes: 18 additions & 56 deletions group_vars/all/mailcow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,6 @@ mailcow__config_skip_http_verification: y
mailcow__upload_results_html: yes
mailcow__upload_results_json: yes

mailcow__lang_files:
- name: CA
file: lang.ca.json
- name: CS
file: lang.cs.json
- name: DE
file: lang.de.json
- name: ES
file: lang.es.json
- name: FI
file: lang.fi.json
- name: FR
file: lang.fr.json
- name: IT
file: lang.it.json
- name: LV
file: lang.lv.json
- name: NL
file: lang.nl.json
- name: PL
file: lang.pl.json
- name: PT
file: lang.pt.json
- name: RO
file: lang.ro.json
- name: RU
file: lang.ru.json
- name: SV
file: lang.sv.json
- name: SK
file: lang.sk.json
- name: HU
file: lang.hu.json
- name: KO
file: lang.ko.json
- name: ZH
file: lang.zh.json

mailcow__pull_images:
- mysql-mailcow
- redis-mailcow
Expand Down Expand Up @@ -77,24 +39,24 @@ mailcow__docker_logs_directory: /opt/mailcow-logs
mailcow__docker_logs_archive_path: "/opt/{{ mailcow__docker_logs_archive_name }}"
mailcow__docker_logs_archive_name: logs-{{ drone_commit_hash }}-{{ mailcow__report_timestamp }}.zip
mailcow__container_names:
- mailcowdockerized_acme-mailcow_1
- mailcowdockerized_clamd-mailcow_1
- mailcowdockerized_dockerapi-mailcow_1
- mailcowdockerized_dovecot-mailcow_1
- mailcowdockerized_ipv6nat-mailcow_1
- mailcowdockerized_memcached-mailcow_1
- mailcowdockerized_mysql-mailcow_1
- mailcowdockerized_netfilter-mailcow_1
- mailcowdockerized_nginx-mailcow_1
- mailcowdockerized_olefy-mailcow_1
- mailcowdockerized_php-fpm-mailcow_1
- mailcowdockerized_postfix-mailcow_1
- mailcowdockerized_redis-mailcow_1
- mailcowdockerized_rspamd-mailcow_1
- mailcowdockerized_sogo-mailcow_1
- mailcowdockerized_solr-mailcow_1
- mailcowdockerized_unbound-mailcow_1
- mailcowdockerized_watchdog-mailcow_1
- mailcowdockerized-acme-mailcow-1
- mailcowdockerized-clamd-mailcow-1
- mailcowdockerized-dockerapi-mailcow-1
- mailcowdockerized-dovecot-mailcow-1
- mailcowdockerized-ipv6nat-mailcow-1
- mailcowdockerized-memcached-mailcow-1
- mailcowdockerized-mysql-mailcow-1
- mailcowdockerized-netfilter-mailcow-1
- mailcowdockerized-nginx-mailcow-1
- mailcowdockerized-olefy-mailcow-1
- mailcowdockerized-php-fpm-mailcow-1
- mailcowdockerized-postfix-mailcow-1
- mailcowdockerized-redis-mailcow-1
- mailcowdockerized-rspamd-mailcow-1
- mailcowdockerized-sogo-mailcow-1
- mailcowdockerized-solr-mailcow-1
- mailcowdockerized-unbound-mailcow-1
- mailcowdockerized-watchdog-mailcow-1

mailcow__hostname_local_part: "mail-{{ drone_commit_hash }}"
mailcow__hostname: "{{ mailcow__hostname_local_part }}.{{ mailcow__dns_zone }}"
Expand Down
5 changes: 1 addition & 4 deletions group_vars/all/testflags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ mailcow__tests_test_sendmail: yes
mailcow__tests_test_app_password: yes

# tests/syncjob.yml
mailcow__tests_test_syncjob: yes

# tests/lang_coverage.yml
mailcow_tests__test_langcoverage: yes
mailcow__tests_test_syncjob: no

# tests/oauth_apps.yml
mailcow_tests__oauth_apps: yes
Expand Down
3 changes: 3 additions & 0 deletions mailcow-delete-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
location: "{{ item.datacenter }}"
state: absent
api_token: "{{ vault__hcloud__token }}"
when: "'{{ ci_hcloud_server_name }}' in item.name"
loop: "{{ hetzner_cloud_stats.hcloud_server_info }}"
no_log: yes

Expand All @@ -28,7 +29,9 @@
name: "{{ item.name }}"
state: absent
api_token: "{{ vault__hcloud__token }}"
when: "'{{ ci_hcloud_server_name }}' in item.name"
loop: "{{ hetzner_cloud_stats.hcloud_server_info }}"
no_log: yes

- name: "Delete a record for {{ mailcow__hostname }}"
community.general.cloudflare_dns:
Expand Down
1 change: 0 additions & 1 deletion mailcow-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
- name: Integration Tests
hosts: all
gather_facts: true
become: yes
roles:
- role: mailcow-tests
tags: [ 'mailcow-tests' ]
Loading

0 comments on commit 98fb52d

Please sign in to comment.