diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index aba623a..8baedc6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -111,16 +111,13 @@ jobs: - name: Prepare docs if: contains(github.ref, 'refs/heads/master') - run: | - git clone -b main https://github.com/terraform-docs/website scripts/docs/website - rm -rf scripts/docs/website/content/ - cp -r docs/ scripts/docs/website/content/ + run: ./scripts/docs/prepare-site.sh - name: Publish to website uses: drud/action-cross-commit@master if: contains(github.ref, 'refs/heads/master') with: - source-folder: scripts/docs/website/content + source-folder: site/content destination-repository: https://${{ secrets.COMMITTER_USERNAME }}:${{ secrets.COMMITTER_TOKEN }}@github.com/terraform-docs/website destination-folder: content destination-branch: main diff --git a/.gitignore b/.gitignore index 4582eeb..af3ec5f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ coverage.txt # goreleaser dist/ + +# website +site/ diff --git a/docs/_index.md b/docs/_index.md index 87748e5..ea5d7d9 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -1,4 +1,5 @@ --- -title : "Generate Terraform module documentation" -description: "Generate documentation from Terraform modules in various output formats." +title : "terraform-docs" +description: "Generate Terraform modules documentation in various formats." +lead: "Generate Terraform modules documentation in various formats." --- diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..18d5baa --- /dev/null +++ b/netlify.toml @@ -0,0 +1,10 @@ +[build] + publish = "site/public" + +[build.environment] + HUGO_VERSION = "0.80.0" + NODE_VERSION = "15.5.1" + NPM_VERSION = "7.3.0" + +[context.deploy-preview] + command = "./scripts/docs/prepare-site.sh && cd site && npm install && hugo -b ${DEPLOY_PRIME_URL} --gc" diff --git a/scripts/docs/prepare-site.sh b/scripts/docs/prepare-site.sh new file mode 100755 index 0000000..6aed65f --- /dev/null +++ b/scripts/docs/prepare-site.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# Copyright 2021 The terraform-docs Authors. +# +# Licensed under the MIT license (the "License"); you may not +# use this file except in compliance with the License. +# +# You may obtain a copy of the License at the LICENSE file in +# the root directory of this source tree. + +set -o errexit +set -o pipefail + +PWD=$(cd "$(dirname "$0")" && pwd -P) +PWD="${PWD}/../.." + +# Make sure site/ folder does not exist +rm -rf "${PWD}"/site + +# Clone the website repository locally +git clone -b main https://github.com/terraform-docs/website "${PWD}"/site + +# Update website content +rm -rf "${PWD}"/site/content/ +cp -r "${PWD}"/docs/ "${PWD}"/site/content/