I’m trying to run below YAML file with a job. How can I specify working directory, if I want this to trigger when there is change in any child folders?
For example: below is the snippet of my working directory structure and I want CI to trigger when I make changes to any child folders under Policy folder.
Any changes in Initiative and Definitions should trigger the event.
What should be the working directory path?
name: 'deployment of azure policies'
on:
push:
branches: [ "main" ]
pull_request:
paths:
- "Policy/Initiatives/*"
jobs:
build-and-deploy:
env:
TF_IN_AUTOMATION: true
TF_INPUT: false
**TF_WORKING_DIR: Policy/Initiatives/**
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
I tried below, but didn’t work:
TF_Working_DIR: "Policy/"
It says no configuration files found (it’s correct as the configuration files are in the child folders).
However, when I mention Policy/Initiatives or Policy/Definitions, the work is working fine.
3
Answers
I created one Github repository with below folders:-
I agree to the answer by @Philip and @jessehouwing
In order to trigger the github actions from child folder you can use
"Policy-Assignment/**/*"
and add the below code in your Github workflow:-Output:-
The workflow ran successfully like below:-
UPDATED:-
You can specify the full path to your folder in your code like below:-
Output:-
Alternatively, You can make use of
find
method in your code to find the files from child folders like below:-Output:-
Initiative i1.json from Initiatives child folder and a.json Policy definition was found and code ran successfully like below:-
Here’s a working "Github" example of a pipeline deploying policies under the "Policies" folder:
You can find the example over HERE.
You can use a
/**
to denote a recursive include.See: