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

fix(docs): Sign commits for documentation changes #257

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

jbuck
Copy link
Member

@jbuck jbuck commented Feb 1, 2025

Once again I need to change a lightbulb https://www.youtube.com/watch?v=AbSehcT19u0

Our story begins with 2 small PRs:

Between these two PRs I noticed that:

  • I wasn't able to merge my PR, because it had some unsigned commits, and this repository requires signed commits
  • The generated documentation was being duplicated by terraform-docs

The reason the generated documentation was being duplicated is because most of our README.md files are missing the block delimeters <!-- BEGIN_TF_DOCS --> and <!-- END_TF_DOCS -->.
So the generated content will be appended at the end of the file.
Well no worries, maybe I just need to add those blocks to our existing README.md files? #256
Close, but I think I need to add .terraform-docs.yml config file to every directory as well. And we need to sign the commits too! Alas

So this PR switches the README.md generation to use signed commits like #240 did.

Changelog entry

fix(docs): Sign commits for documentation changes

@jbuck jbuck requested a review from amitchell-moz February 1, 2025 19:18
@jbuck jbuck added the no-release This PR won't increment any versions label Feb 1, 2025
@@ -87,26 +87,34 @@ runs:
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Check for terraform-docs.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this part getting deleted? Without this, changes to any folder without a .terraform-docs.yml will fail CI

Copy link
Member Author

@jbuck jbuck Feb 3, 2025

Choose a reason for hiding this comment

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

Ahh, okay, I definitely read this part wrong. I was simply interpreting it as "I always want to run terraform-docs step, so I need to delete this if check."

Sounds like I should add a terraform-docs.yml configuration for each module in this PR, right? I guess combine this PR and #256 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you revert the deletion of this section and restore the if: ${{ steps.tf_docs.outputs.tf_docs == 'true' }}, then you don't need a .terraform-docs.yml.

The logic here is "if tf-docs.yml exists in the module folder, regenerate the readme with it; otherwise do nothing"

Copy link
Member Author

Choose a reason for hiding this comment

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

So, if I want docs automatically generated for each PR, I should add .terraform-docs.yml right?

Follow-up question - should I make this PR only to get commit signing working (and thus, restore the if check)? And then I can use #256 to have documentation generated automatically for all modules?

Copy link
Contributor

Choose a reason for hiding this comment

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

So if you want all of the modules in https://github.com/mozilla/terraform-modules/pull/256/files to get auto-readmes, they would need .teraform-docs.yml in addition to those BEGIN_TF_DOCS blocks.

I think you could just symlink in the .teraform-docs.yml from the root of the repo if you want to save a little work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, reverted the if change and this is ready for re-review!

@jbuck jbuck force-pushed the terraform-docs-git-push-signed-commits branch from bd61f0c to 9fc57e3 Compare February 3, 2025 17:27
@jbuck jbuck requested a review from amitchell-moz February 3, 2025 17:27
@jbuck jbuck force-pushed the terraform-docs-git-push-signed-commits branch from 9fc57e3 to edfa733 Compare February 3, 2025 17:28
Copy link
Contributor

@amitchell-moz amitchell-moz left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for fixing this!

@jbuck jbuck merged commit a18817f into main Feb 3, 2025
8 checks passed
@jbuck jbuck deleted the terraform-docs-git-push-signed-commits branch February 3, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-release This PR won't increment any versions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants