ci: added ci pipelines
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
2022-05-26 23:17:00 +02:00
parent d5e9fe017f
commit 5cf2f5d7a5
5 changed files with 141 additions and 1 deletions

62
.drone.yml Normal file
View File

@@ -0,0 +1,62 @@
---
kind: pipeline
type: kubernetes
name: Vet
trigger:
event:
- push
- tag
environment:
TF_IN_AUTOMATION: "1"
steps:
- name: get terraform
image: hashicorp/terraform:1.1.8
commands:
- mv /bin/terraform .
- name: Generate docs
image: ubuntu:22.04
commands:
- wget https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz -O - | tar -xz terraform-docs -C /usr/local/bin
- scripts/generate-docs.sh
- scripts/format.sh
- rm terraform
- apt-get update && apt-get install git
- git diff-index --name-status HEAD
---
kind: pipeline
type: kubernetes
name: Terraform validate
trigger:
event:
- push
- tag
branch:
- main
environment:
TF_IN_AUTOMATION: "1"
steps:
- name: terraform init
image: hashicorp/terraform:1.1.8
commands:
- mkdir -p ~/.ssh
- chmod 755 ~/.ssh
- echo "$${CI_SSH_KEY}" | base64 -d > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- scripts/validate.sh
environment:
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
CI_SSH_KEY:
from_secret: ci-ssh-key
---
kind: signature
hmac: 90482a009148fec8cf811a4dc5d71005fe6cef860474141964b2b36e16cbf6d6
...

35
.gitignore vendored Normal file
View File

@@ -0,0 +1,35 @@
# Local .terraform directories
**/.terraform/*
# .tfstate files
*.tfstate
*.tfstate.*
# Crash log files
crash.log
crash.*.log
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json
# Include override files you do wish to add to version control using negated pattern
# !example_override.tf
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
# Ignore CLI configuration files
.terraformrc
terraform.rc

21
scripts/format.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
for DIR in $(find . -type d); do
if [[ "${DIR}" = "." ]] || [[ $(echo ${DIR} | cut -c1-5) = ".git/" ]]; then
continue;
fi
pushd $DIR
terraform_files=$(find . -maxdepth 1 -type f -iname '*.tf')
if [[ ${#terraform_files} -eq 0 ]]; then
popd
continue
fi
terraform fmt
popd
done

View File

@@ -15,4 +15,4 @@ for DIR in $(find . -type d); do
terraform-docs markdown document . > README.md terraform-docs markdown document . > README.md
popd popd
done done

22
scripts/validate.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
set -euo pipefail
for DIR in $(find . -type d); do
if [[ "${DIR}" = "." ]] || [[ $(echo ${DIR} | cut -c1-5) = ".git/" ]]; then
continue;
fi
pushd $DIR
terraform_files=$(find . -maxdepth 1 -type f -iname '*.tf')
if [[ ${#terraform_files} -eq 0 ]]; then
popd
continue
fi
terraform init
terraform validate
popd
done