-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (96 loc) · 2.96 KB
/
deploy_docs.yml
File metadata and controls
112 lines (96 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Workflow for building and deploying MkDocs documentation with Terraform docs to GitHub Pages
name: Deploy Documentation to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: [main]
paths:
- 'docs/**'
- 'mkdocs.yml'
- '*.tf'
- 'modules/**'
- 'schemas/**'
- 'examples/**'
- '.github/workflows/deploy_docs.yml'
pull_request:
types: [opened, synchronize]
paths:
- 'docs/**'
- 'mkdocs.yml'
- '*.tf'
- 'modules/**'
- 'schemas/**'
- 'examples/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
# Default to bash
defaults:
run:
shell: bash
jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
TERRAFORM_DOCS_VERSION: v0.20.0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git revision dates
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'docs/requirements.txt'
- name: Install MkDocs and dependencies
run: |
pip install -r docs/requirements.txt
- name: Install terraform-docs
run: |
wget -O /tmp/terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/${TERRAFORM_DOCS_VERSION}/terraform-docs-${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz
tar -xzf /tmp/terraform-docs.tar.gz -C /tmp
sudo mv /tmp/terraform-docs /usr/local/bin/
chmod +x /usr/local/bin/terraform-docs
terraform-docs --version
- name: Generate Terraform documentation
run: |
# Generate main module docs
terraform-docs markdown table . > docs/reference/terraform.md
# Generate submodule docs
for dir in modules/*/; do
module_name=$(basename $dir)
terraform-docs markdown table $dir > docs/reference/module-${module_name}.md
done
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with MkDocs
run: |
mkdocs build --strict --site-dir ./site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site
# Deployment job
deploy:
if: github.event_name == 'push' || github.event.pull_request.merged == true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4