From bb73c9245b8fce7ca6cefe0b65f5508e6921ad07 Mon Sep 17 00:00:00 2001 From: Timothy MacDonald Date: Mon, 9 Oct 2023 14:39:48 -0500 Subject: [PATCH] docs(readme): automate update and testing of README.md by terraform-docs Add github action to test that README.md has been update. Also add update of README.md to /scripts/release.sh prepare Signed-off-by: Timothy MacDonald --- .github/.workflows/terraform_docs.yml | 18 ----------------- .github/workflows/terraform_docs.yml | 29 +++++++++++++++++++++++++++ scripts/release_helpers.sh | 7 ++++++- 3 files changed, 35 insertions(+), 19 deletions(-) delete mode 100644 .github/.workflows/terraform_docs.yml create mode 100644 .github/workflows/terraform_docs.yml diff --git a/.github/.workflows/terraform_docs.yml b/.github/.workflows/terraform_docs.yml deleted file mode 100644 index 2ec2082..0000000 --- a/.github/.workflows/terraform_docs.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Generate terraform docs -on: - - pull_request -jobs: - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - - name: Render terraform docs inside the README.md and push changes back to PR branch - uses: terraform-docs/gh-actions@v1.0.0 - with: - working-dir: . - output-file: README.md - output-method: inject - git-push: "true" \ No newline at end of file diff --git a/.github/workflows/terraform_docs.yml b/.github/workflows/terraform_docs.yml new file mode 100644 index 0000000..276d534 --- /dev/null +++ b/.github/workflows/terraform_docs.yml @@ -0,0 +1,29 @@ +name: Test that terraform docs has been run +on: push +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + - name: Install terraform-docs + run: curl -L https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz | (cd /usr/local/bin; tar zxvf -; chmod +x /usr/local/bin/terraform-docs) + - name: store hash of orig README.md + id: old_hash + run: echo "README_HASH=$(md5sum README.md)" >> $GITHUB_OUTPUT + - name: Update README.md using terraform-docs make target + run: make terraform-docs + - name: store hash of new README.md + id: new_hash + run: echo "README_HASH=$(md5sum README.md)" >> $GITHUB_OUTPUT + - name: echo hashes + run: | + echo ${{ steps.old_hash.outputs.README_HASH }} + echo ${{ steps.new_hash.outputs.README_HASH }} + - name: test to see of hashs are the same + if: ${{ steps.old_hash.outputs.README_HASH != steps.new_hash.outputs.README_HASH }} + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Please run "make terraform-docs" and try again') \ No newline at end of file diff --git a/scripts/release_helpers.sh b/scripts/release_helpers.sh index d9a8235..3106297 100644 --- a/scripts/release_helpers.sh +++ b/scripts/release_helpers.sh @@ -1,6 +1,6 @@ # # Name:: release_helpers.sh -# Description:: A set of helper funtions to be used by our release.sh script +# Description:: A set of helper functions to be used by our release.sh script # Author:: Salim Afiune Maya () # @@ -137,6 +137,7 @@ prepare_release() { prerequisites remove_tag_version check_for_minor_version_bump + generate_readme generate_release_notes update_changelog push_release @@ -192,6 +193,10 @@ generate_release_notes() { echo "$(cat CHANGES.md)" >> RELEASE_NOTES.md } +generate_readme() { + make terraform-docs +} + load_list_of_changes() { latest_version=$(find_latest_version) local _list_of_changes=$(git log --no-merges --pretty="* %s (%an)([%h](https://github.com/${org_name}/${project_name}/commit/%H))" ${latest_version}..${main_branch})