-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add terraform format and docs generation
- Loading branch information
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Generate terraform docs | ||
|
||
on: | ||
pull_request: | ||
types: ["opened", "synchronize"] | ||
|
||
env: | ||
GOPROXY: https://proxy.golang.org,direct | ||
DEBIAN_FRONTEND: noninteractive | ||
GO_VERSION: "1.23" | ||
|
||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_wrapper: false | ||
- name: Format and generate docs | ||
run: go generate ./... | ||
- name: Check for changes | ||
id: check_changes | ||
run: | | ||
if [[ -n "$(git diff --exit-code)" ]]; then | ||
echo "Changes detected." | ||
echo "::set-output name=has_changes::true" | ||
else | ||
echo "No changes detected." | ||
echo "::set-output name=has_changes::false" | ||
fi | ||
- name: Commit and push Changes | ||
if: steps.check_changes.outputs.has_changes == 'true' | ||
run: | | ||
# configure user | ||
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
# stage any file changes to be committed | ||
git add . | ||
# make commit with staged changes | ||
git commit -m 'Terraform format/docs changes' | ||
# push the commit back up to source GitHub repository | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
//go:build tools | ||
//go:build generate | ||
|
||
package tools | ||
|
||
import ( | ||
// Ensure documentation generator is not removed from go.mod. | ||
_ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" | ||
) | ||
|
||
// format terraform code for use in documentation | ||
//go:generate terraform fmt -recursive ../examples/ | ||
|
||
// generate documentation | ||
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-dir .. -provider-name adguard |