Skip to content

Commit

Permalink
ci: add centralized workflows for the devops-stack modules
Browse files Browse the repository at this point in the history
docs: shortened comment

feat: change version on the variable file
  • Loading branch information
lentidas committed Oct 24, 2022
1 parent f310e28 commit 71d37dd
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/modules-linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# GitHub Actions workflow to check that the Terraform code is well formatted and if the commits have the conventional
# commit message structure (the latter is needed to properly create automatic releases with Release Please).
#
# IMPORTANT: This workflow is called by other workflows in our DevOps Stack repositories and it is centralized here in
# order to be easily maintained across modules. Because of this, please make sure you're not introducing any breaking
# changes when modifying this workflow.

name: "Linters"

on:
workflow_call:

jobs:
terraform-format:
runs-on: ubuntu-latest

steps:
- name: "Check out the repository"
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2

- name: "Run terraform fmt -check"
run: "terraform fmt -check"

commits-checks:
runs-on: ubuntu-latest

steps:
- name: "Check out the repository"
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: "Check commit messages"
uses: docker://aevea/commitsar
22 changes: 22 additions & 0 deletions .github/workflows/modules-release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# GitHub Actions workflow to automatically create releases and changelogs in our DevOps Stack repositories.
#
# IMPORTANT: This workflow is called by other workflows in our DevOps Stack repositories and it is centralized here in
# order to be easily maintained across modules. Because of this, please make sure you're not introducing any breaking
# changes when modifying this workflow.

name: "Release Modules"

on:
workflow_call:

jobs:
release-please:
runs-on: "ubuntu-latest"
steps:
- uses: "google-github-actions/release-please-action@v3"
with:
release-type: "simple"
bump-minor-pre-major: true
extra-files: |
variables.tf
82 changes: 82 additions & 0 deletions .github/workflows/modules-terraform-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# GitHub Actions workflow to automatically generate documentation from the .tf files of the module.
# The generated documentation will be injected between AsciiDoc comments on the README.adoc.
#
# IMPORTANT: This workflow is called by other workflows in our DevOps Stack repositories and it is centralized here in
# order to be easily maintained across modules. Because of this, please make sure you're not introducing any breaking
# changes when modifying this workflow.

name: "Terraform Docs"

on:
workflow_call:
inputs:
variants:
# List of the variants folders as a comma-separated list inside a string (i.e. "eks,aks,sks").
type: string
required: false
default: ""

jobs:
terraform-docs:
runs-on: ubuntu-latest

steps:
- name: "Check out the repository"
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: "Generate Terraform docs"
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: .
indention: 3
output-format: asciidoc document
output-file: README.adoc
output-method: inject
template: "// BEGIN_TF_DOCS\n{{ .Content }}\n// END_TF_DOCS" # Define template compatible with AsciiDoc
git-push: false

- name: "Generate Terraform tables"
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: .
indention: 1 # Since the headings are not read inside the collapsible block we can indent as 1
output-format: asciidoc table
output-file: README.adoc
output-method: inject
template: "// BEGIN_TF_TABLES\n{{ .Content }}\n// END_TF_TABLES" # Define template compatible with AsciiDoc
args: "--hide-empty=true" # Do not show empty sections
git-push: false

- name: "Generate Terraform docs for the variants"
if: ${{ inputs.variants != '' }}
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: ${{ inputs.variants }}
indention: 3
output-format: asciidoc document
output-file: README.adoc
output-method: inject
template: "// BEGIN_TF_DOCS\n{{ .Content }}\n// END_TF_DOCS" # Define template compatible with AsciiDoc
git-push: false

- name: "Generate Terraform tables for the variants"
if: ${{ inputs.variants != '' }}
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: ${{ inputs.variants }}
indention: 1 # Since the headings are not read inside the collapsible block we can indent as 1
output-format: asciidoc table
output-file: README.adoc
output-method: inject
template: "// BEGIN_TF_TABLES\n{{ .Content }}\n// END_TF_TABLES" # Define template compatible with AsciiDoc
args: "--hide-empty=true" # Do not show empty sections
git-push: false

# This step avoids a commit for each previous step and instead commits everything on a single commit
- name: "Commit changes done in the previous steps"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "docs(terraform-docs): generate docs and write to README.adoc"

0 comments on commit 71d37dd

Please sign in to comment.