Skip to content

Commit

Permalink
ci: update docs workflow (#83)
Browse files Browse the repository at this point in the history
* ci: fix docs workflow

* chore: add requirements

* ci: remove team reviewers

* chore

* chore: sort module library

* ci: run on schedule
  • Loading branch information
hknutsen authored Dec 7, 2023
1 parent 1d448f7 commit 95b226b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: docs

on:
# schedule:
# - cron: "0 3 * * 1-5" # At 03:00 on every day-of-week from Monday through Friday.
schedule:
- cron: "0 3 * * 1-5" # At 03:00 on every day-of-week from Monday through Friday.

workflow_dispatch: {}

jobs:
docs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: scripts/module-library

env:
OUTPUT_PATH: ${{ github.workspace }}/docs/module-library.md

Expand All @@ -21,8 +25,12 @@ jobs:
with:
python-version: 3.12.0

- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Python script
working-directory: scripts/module-library
run: ./module-library.py -t template.md -o "$OUTPUT_PATH"

- name: Create PR
Expand All @@ -36,4 +44,3 @@ jobs:
base: main
title: "docs: update module library"
body: ""
team-reviewers: terraform-baseline
11 changes: 6 additions & 5 deletions scripts/module-library/module-library.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
response = requests.get(url)
responseJson = response.json()
repos = responseJson.get("items")
reposSorted = sorted(repos, key=lambda repo: repo["name"])

####################################################################################
# Create Markdown table containing all Terraform Baseline modules
Expand All @@ -34,8 +35,8 @@

dict = {
"Module": "{moduleName}",
"Repository": "[{repoName}]({repoUrl})",
"Latest release": "{latestRelease}",
"Repository": "[{repoFullName}]({repoUrl})",
"Latest release": "[![Release](https://img.shields.io/github/v/release/{repoFullName}?display_name=tag&sort=semver)]({repoUrl}/releases)",
}

columns = dict.keys()
Expand All @@ -44,18 +45,18 @@

row = columnSeparator.join(dict.values())

for repo in repos:
for repo in reposSorted:
repoName = repo.get("name", "N/A")
moduleName = repoName.replace("terraform-azurerm-", "")
repoFullName = repo.get("full_name", "N/A")
repoUrl = repo.get("html_url", "N/A")
latestRelease = repo.get("latest_release", "N/A")

rows.append(
row.format(
moduleName=moduleName,
repoName=repoName,
repoFullName=repoFullName,
repoUrl=repoUrl,
latestRelease=latestRelease,
)
)

Expand Down
1 change: 1 addition & 0 deletions scripts/module-library/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests==2.31.0

0 comments on commit 95b226b

Please sign in to comment.