infra/.drone.yml

31 lines
1.1 KiB
YAML
Raw Normal View History

2021-02-12 21:42:16 +00:00
kind: pipeline
type: kubernetes
name: default
steps:
2021-02-14 18:23:49 +00:00
- name: Prepare terraform files
2021-02-12 21:42:16 +00:00
image: alpine
commands:
2021-02-14 13:17:24 +00:00
- "apk update && apk add jq curl git git-crypt"
2021-02-12 21:42:16 +00:00
- |
2021-02-14 13:17:24 +00:00
curl -k https://kubernetes:6443/api/v1/namespaces/drone/configmaps/git-crypt-key -H "Authorization:Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" | jq -r .data.key | base64 -d > /tmp/key
- "git-crypt unlock /tmp/key"
2021-02-12 21:42:16 +00:00
- name: Terraform apply
image: hashicorp/terraform:latest
2021-02-14 13:17:24 +00:00
environment:
TF_VAR_prod: "true"
2021-02-12 21:42:16 +00:00
commands:
2021-02-13 02:10:39 +00:00
- "terraform init"
2021-02-14 18:23:49 +00:00
- "terraform apply -target=module.kubernetes_cluster -auto-approve"
2021-02-13 02:10:39 +00:00
2021-02-14 18:23:49 +00:00
- name: Push commit
image: alpine
commands:
- "apk update && apk add openssh-client git git-crypt"
- "mkdir ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts"
- 'chmod 400 secrets/deploy_key'
- "git add ."
- "git remote set-url origin git@github.com:ViktorBarzin/infra.git"
- "git commit -m 'Drone CI deploy commit' || echo 'No changes'"
- "GIT_SSH_COMMAND='ssh -i ./secrets/deploy_key -o IdentitiesOnly=yes' git push origin master"