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

Feat/docs auto updater #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions .github/workflows/doc_sync.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
name: Doc synchronization
# Check docs are up-to-date only on pull request.
# Succeeds if it is.
# Fail if not, generates a new version then commits it.

name: Docs synchronizer

on:
push:
branches:
- master
pull_request:
branches:
- master
branches: [master]
workflow_dispatch:

permissions:
contents: read

jobs:
doc-sync:
name: check if doc is generate
docs-synch:
name: Auto-updates docs on pull requests when needed
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: sets up go environnement
uses: actions/setup-go@v4
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Get dependencies
run: go mod download

- name: Install tfplugindocs
run: go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
- name: Run tfplugindocs
run: go generate ./...

- name: Fail if any files changed
shell: bash
run: |
if [[ $(git status --porcelain=v1 docs/ | wc -l) -ne 0 ]]; then
echo "Please ensure tfplugindocs changes are committed to docs/"
echo "docs/ needs an update"
echo "Changed files:"
git diff docs/
git status docs/
exit 1
fi
fi

- name: Commit docs update
if: |
failure()
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: auto-update documentations
file_pattern: 'docs/'
commit_user_name: Docs synchronizer Bot
commit_user_email: [email protected]
Loading