Rizbe
(Rizbe)
1
Looking to Automate Terraform using Done. One of the issues I have run into is that I don’t see a way to get the GitHub path of the files changed
For example:
repo:rds/main.tf
repo:es/main.tf
Depending on what file was changed, would like to cd into that path and run Terraform.
kodelint
(Satyajit Roy)
2
@Rizbe I have done something similar but instead of asking drone about the changed files I used git to give me that information.
---
kind: pipeline
type: docker
name: terraform-run-my-repo
workspace:
path: my-repo
steps:
- name: validate
image: docker-searchops-images-release.dr.corp.adobe.com/ci-runner:v1.13
pull: true
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: STG_AWS_SECRET_ACCESS_KEY
GIT_TOKEN:
from_secret: GIT_TOKEN
commands:
- cd my-repo
- git fetch --no-tags origin +${DRONE_COMMIT_REF}
- git checkout -qf FETCH_HEAD
- ci plan SecurityGroups
when:
event:
- pull_request
The script
which does that for me is the ci
script which has 2 fucntions
get_commited_files() {
git diff-tree --no-commit-id --name-only --diff-filter=d -r ${DRONE_COMMIT_HASH} > /drone/src/.commited_files.tmp
}
get_commited_files_after_merge() {
git log -m -1 --name-only --diff-filter=d --pretty="format:" ${DRONE_COMMIT_HASH} > /drone/src/.commited_files.tmp
}