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

Adding git-sub-dir #138

Merged
merged 1 commit into from
Sep 9, 2024
Merged

Conversation

timothyclarke
Copy link

Description of your changes

Fixes #102

This action does not currently support code checked out to a directory other than the default

The following checkout would not work without this PR.

    - name: Checkout - Modules
      uses: actions/checkout@v4
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        ref: ${{ github.event.pull_request.head.ref }}
        fetch-depth: 0
        path: modules

The above would generate the following error

fatal: not a git repository (or any parent up to mount point /github)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Additionally if other repo's are checked out as a subdirectory this will commit that repo as sub-module. While this PR does not directly address the sub-module issue it allows its avoidance by supporting a directory other than /github/workspace

By introducing the git-sub-dir arg and passing that arg to the container we can append the directory. Then everything works as normal

I have:

How has this code been tested

I tested this by using the action timothyclarke/tf-docs-gh-actions@d014534410793a9188ee6b3f1d465505e403db01 main...timothyclarke:tf-docs-gh-actions:checkout-dir

Note that branch is slightly different from this PR as I needed to build the docker container and then reference my docker container.

With the above checkout command and the the following action

      - name: Terraform Docs
        #uses: terraform-docs/gh-actions@v1.2.0
        uses: timothyclarke/tf-docs-gh-actions@d014534410793a9188ee6b3f1d465505e403db01
        with:
          output-file: README.md
          output-method: inject
          git-push: "true"
          git-sub-dir: modules

The test output was

Run timothyclarke/tf-docs-gh-actions@d014534410793a9188ee6b3f1d465505e403db01
  with:
    output-file: README.md
    output-method: inject
    git-push: true
    git-sub-dir: modules
    config-file: disabled
    working-dir: .
    atlantis-file: disabled
    find-dir: disabled
    recursive: false
    recursive-path: modules
    output-format: markdown table
    template: <!-- BEGIN_TF_DOCS -->
  {{ .Content }}
  <!-- END_TF_DOCS -->
    indention: 2
    git-commit-message: terraform-docs: automated action
    git-push-sign-off: false
    fail-on-diff: false
  env:
    pythonLocation: /home/runner/_work/_tool/Python/3.12.5/x64
    PKG_CONFIG_PATH: /home/runner/_work/_tool/Python/3.12.5/x64/lib/pkgconfig
    Python_ROOT_DIR: /home/runner/_work/_tool/Python/3.12.5/x64
    Python2_ROOT_DIR: /home/runner/_work/_tool/Python/3.12.5/x64
    Python3_ROOT_DIR: /home/runner/_work/_tool/Python/3.12.5/x64
    LD_LIBRARY_PATH: /home/runner/_work/_tool/Python/3.12.5/x64/lib
    TERRAFORM_CLI_PATH: /home/runner/_work/_temp/781f4ff4-5bf4-4547-9c99-2ffc986ec800
Using non-standard GITHUB_WORKSPACE of /github/workspace/modules
::debug working_dir=.
::debug output_mode=inject
::debug output_file=README.md
::debug terraform-docs markdown table --indent 2 --output-mode inject --output-file README.md --output-template <!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS --> .
README.md updated successfully
::debug No change in ./ detected
::debug No files changed, skipping commit

@TimothyClarkeTide
Copy link

@khos2ow Any chance someone could take a look at this ?

README.md Outdated Show resolved Hide resolved
git_setup() {
# When the runner maps the $GITHUB_WORKSPACE mount, it is owned by the runner
# user while the created folders are owned by the container user, causing this
# error. Issue description here: https://github.com/actions/checkout/issues/766
git config --global --add safe.directory /github/workspace
git config --global --add safe.directory ${GITHUB_WORKSPACE}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think shellcheck wants this to be…

Suggested change
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git config --global --add safe.directory "${GITHUB_WORKSPACE}"

@pascal-hofmann
Copy link
Contributor

@timothyclarke Can you have a look at the failing checks?

@timothyclarke
Copy link
Author

@pascal-hofmann I've done the shellcheck per your suggestion. Hopefully that works.

I've also done a %s/1.2.0/1.2.1/g in the readme.md. Hopefully that address that one too.

@pascal-hofmann
Copy link
Contributor

I've also done a %s/1.2.0/1.2.1/g in the readme.md. Hopefully that address that one too.

Thank you. Somehow validate/readme is still unhappy though. :(

@timothyclarke
Copy link
Author

@pascal-hofmann

I need to look a little deeper into this one as I don't have the gompile binary that scripts/update-readme.sh requires.

The Contributing.md doesn't mention this so as soon as I have a better idea on that part I'll update.

Note on the contributiing.md, the good hygiene link no longer works

Signed-off-by: Timothy Clarke <Timothy.Clarke@ServerBox.co.uk>
@timothyclarke
Copy link
Author

@pascal-hofmann I think it's all fixed now.
It looks like the core Readme change was the description in the table must match the description in action.yml. I guess that one is a "Well daaa!".

I've also uploaded Contributing.md so anyone else coming along should be able to address these sorts of issues before seeing failing tests.

@pascal-hofmann pascal-hofmann merged commit 89278fb into terraform-docs:main Sep 9, 2024
5 checks passed
@pascal-hofmann
Copy link
Contributor

@timothyclarke Thanks for work on this!

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

Successfully merging this pull request may close these issues.

fatal: not a git repository (or any parent up to mount point /github)
3 participants