Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run docs only on folders where content has changed #25

Open
Marcus-James-Adams opened this issue Nov 26, 2020 · 1 comment
Open

run docs only on folders where content has changed #25

Marcus-James-Adams opened this issue Nov 26, 2020 · 1 comment

Comments

@Marcus-James-Adams
Copy link

Marcus-James-Adams commented Nov 26, 2020

I think this is what #17 is referencing.

But we too run a mono repo for lots of projects.

It may be that the solution is with int git hub actions side of things to only pass to tf_docs_working_dir a list of folders where the code has actually changed

I would like the ability to restrict docs to execute only in those subfolders that contain terraform code that has actually changed. This is to avoid docs files being recreated on folders with no changes and skewing timestamps and diffs.

@tomasbackman
Copy link

Would be a nice addition in the action.

We solved this by adding another run bash step that return the changed module as a list which terraform doc uses:

     - uses: actions/checkout@v2
        with:
          ref: ${{ github.ref }}
          fetch-depth: 0

      - name: Get changed modules
        shell: bash
        run: |
          BLOCK_LIST=(".github" "bin" "_example-module" "configs")
          CHANGED_FILES=$(git diff --name-only origin/master..${{ github.ref }} | cut -f1 -d'/' | sort -u)
          for FILE in $CHANGED_FILES; do
            # Ignore all entries in blocklist
            [[ " ${BLOCK_LIST[@]} " =~ " $FILE " ]] && continue
            # Ignore all entries that are not folders, and append to MODULES variable
            [[ -d ${FILE} ]] && MODULES="${MODULES},${FILE}"
          done
          # Strip the first comma from the list of modules and make it an environment variable
          echo "Modules that have been changed: ${MODULES:1}"
          echo MODULES=${MODULES:1} >> $GITHUB_ENV
          
       - name: Automatically generated docs
        uses: Dirrk/[email protected] 
        with:
          tf_docs_working_dir: ${{ env.MODULES }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants