I am trying to implement Github Actions for Terraform Plan and Apply using Github Pull Request and Merge features.
What I am not able to achieve is, reusing the workflow for every new component in the project.
For example, I have to add a new microservice in the project, I have created a Terraform module as below,
#new-microservice.tf
module "new-microservice" {
source = "",
name = "foo",
nlb = true,
few other details
}
So, when a new microservice needs to be added into the project, anyone can create new TF file with module block by changing the values of the attributes.
#one-more-microservice.tf
module "one-more-microservice" {
source = "",
name = "bar",
nlb = false,
few other details
}
So far, so good. Issue arrives when I want to isolate each of this microservice's resource states.
Each of this TF files will go into a separate directory in the Git repo so that TF state will be isolated.
But, with Github Actions, workflow yaml should be kept in .github/workflow directory of the Git repository.
How can I find the directory which has changes in the pull request and run the workflow inside that directory?
I tried searching in the Github Actions Marketplace, couldn't find anything concrete.
I don't want to create multiple jobs inside the plan and deploy workflow yaml files, one for microservice.