Skip to content

Commit 5d2a924

Browse files
authored
Initial commit
0 parents  commit 5d2a924

23 files changed

+1481
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Generate terraform docs
2+
on:
3+
- pull_request
4+
jobs:
5+
docs:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
with:
10+
ref: ${{ github.event.pull_request.head.ref }}
11+
12+
- name: Render terraform docs inside the README.md and push changes back to PR branch
13+
uses: terraform-docs/[email protected]
14+
with:
15+
working-dir: .
16+
config-file: .terraform-docs.yml
17+
git-push: "true"

.github/workflows/pr-title.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Validate PR title'
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
name: Validate PR title
13+
runs-on: ubuntu-latest
14+
steps:
15+
# Please look up the latest version from
16+
# https://github.com/amannn/action-semantic-pull-request/releases
17+
- uses: amannn/action-semantic-pull-request@v4
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
# Configure which types are allowed.
22+
# Default: https://github.com/commitizen/conventional-commit-types
23+
types: |
24+
feat
25+
fix
26+
improvement
27+
docs
28+
refactor
29+
test
30+
ci
31+
chore
32+
# Configure that a scope must always be provided.
33+
requireScope: false
34+
# Configure additional validation for the subject based on a regex.
35+
# This example ensures the subject starts with an uppercase character.
36+
subjectPattern: ^[A-Z].+$
37+
# If `subjectPattern` is configured, you can use this property to override
38+
# the default error message that is shown when the pattern doesn't match.
39+
# The variables `subject` and `title` can be used within the message.
40+
subjectPatternError: |
41+
The subject "{subject}" found in the pull request title "{title}"
42+
didn't match the configured pattern. Please ensure that the subject
43+
starts with an uppercase character.
44+
# For work-in-progress PRs you can typically use draft pull requests
45+
# from Github. However, private repositories on the free plan don't have
46+
# this option and therefore this action allows you to opt-in to using the
47+
# special "[WIP]" prefix to indicate this state. This will avoid the
48+
# validation of the PR title and the pull request checks remain pending.
49+
# Note that a second check will be reported if this is enabled.
50+
wip: true

.github/workflows/pre-commit.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Pre-Commit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- master
8+
9+
env:
10+
TERRAFORM_DOCS_VERSION: v0.16.0
11+
# TFLINT_VERSION: v0.41.0 # use this version with "Invicton-Labs/deepmerge/null" module
12+
13+
jobs:
14+
collectInputs:
15+
name: Collect workflow inputs
16+
runs-on: ubuntu-latest
17+
outputs:
18+
directories: ${{ steps.dirs.outputs.directories }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Get root directories
24+
id: dirs
25+
uses: clowdhaus/terraform-composite-actions/[email protected]
26+
27+
preCommitMinVersions:
28+
name: Min TF pre-commit
29+
needs: collectInputs
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
38+
- name: Terraform min/max versions
39+
id: minMax
40+
uses: clowdhaus/[email protected]
41+
with:
42+
directory: ${{ matrix.directory }}
43+
44+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
45+
# Run only validate pre-commit check on min version supported
46+
if: ${{ matrix.directory != '.' }}
47+
uses: clowdhaus/terraform-composite-actions/[email protected]
48+
with:
49+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
50+
args: "terraform-validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*"
51+
52+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
53+
# Run only validate pre-commit check on min version supported
54+
if: ${{ matrix.directory == '.' }}
55+
uses: clowdhaus/terraform-composite-actions/[email protected]
56+
with:
57+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
58+
args: "terraform-validate --color=always --show-diff-on-failure --files $(ls *.tf)"
59+
60+
preCommitMaxVersion:
61+
name: Max TF pre-commit
62+
runs-on: ubuntu-latest
63+
needs: collectInputs
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v2
67+
with:
68+
ref: ${{ github.event.pull_request.head.ref }}
69+
repository: ${{github.event.pull_request.head.repo.full_name}}
70+
71+
- name: Terraform min/max versions
72+
id: minMax
73+
uses: clowdhaus/[email protected]
74+
75+
# Step required as tflint pre-commit hook requires module to be initialised
76+
- run: terraform init
77+
78+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
79+
uses: clowdhaus/terraform-composite-actions/[email protected]
80+
with:
81+
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
82+
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
83+
# tflint-version: ${{ env.TFLINT_VERSION }} # use this version with "Invicton-Labs/deepmerge/null" module

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Create new release with changelog
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 100
14+
15+
- name: Check release label
16+
id: release-label
17+
uses: actions-ecosystem/action-release-label@v1
18+
if: ${{ github.event.pull_request.merged == true }}
19+
20+
- name: Get latest tag
21+
id: get-latest-tag
22+
uses: actions-ecosystem/action-get-latest-tag@v1
23+
if: ${{ steps.release-label.outputs.level != null }}
24+
25+
- name: Bump semantic version
26+
id: bump-semver
27+
uses: actions-ecosystem/action-bump-semver@v1
28+
if: ${{ steps.release-label.outputs.level != null }}
29+
with:
30+
current_version: ${{ steps.get-latest-tag.outputs.tag }}
31+
level: ${{ steps.release-label.outputs.level }}
32+
33+
- name: Tag release
34+
id: tag-relese
35+
uses: actions-ecosystem/action-push-tag@v1
36+
if: ${{ steps.release-label.outputs.level != null }}
37+
with:
38+
tag: ${{ steps.bump-semver.outputs.new_version }}
39+
message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}"
40+
41+
- name: Generate new release with changelog
42+
id: release-with-changelog
43+
uses: fregante/release-with-changelog@v3
44+
if: ${{ steps.bump-semver.outputs.new_version != null }}
45+
with:
46+
token: "${{ secrets.GITHUB_TOKEN }}"
47+
exclude: '^meta|^docs|^document|^lint|^ci|^refactor|readme|workflow|bump|dependencies|yml|^v?\d+\.\d+\.\d+'
48+
tag: "${{ steps.bump-semver.outputs.new_version }}"
49+
title: "Version ${{ steps.bump-semver.outputs.new_version }}"
50+
commit-template: "- {title} ← {hash}"
51+
skip-on-empty: true
52+
template: |
53+
### Changelog
54+
55+
{commits}
56+
57+
{range}
58+
59+
- name: Comment PR
60+
id: add-comment
61+
uses: actions-ecosystem/action-create-comment@v1
62+
if: ${{ steps.bump-semver.outputs.new_version != null }}
63+
with:
64+
github_token: ${{ secrets.GITHUB_TOKEN }}
65+
number: ${{ steps.get-merged-pull-request.outputs.number }}
66+
body: |
67+
The new version [${{ steps.bump-semver.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.bump-semver.outputs.new_version }}) has been released :tada:

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
### Terraform template
2+
# Local .terraform directories
3+
.terraform
4+
5+
# .tfstate files
6+
*.tfstate
7+
*.tfstate.*
8+
9+
# Crash log files
10+
crash.log
11+
12+
# terraform.lock.hcl files
13+
.terraform.lock.hcl
14+
15+
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
16+
# password, private keys, and other secrets. These should not be part of version
17+
# control as they are data points which are potentially sensitive and subject
18+
# to change depending on the environment.
19+
#
20+
terraform.tfvars
21+
22+
# Ignore override files as they are usually used to override resources locally and so
23+
# are not checked in
24+
override.tf
25+
override.tf.json
26+
*_override.tf
27+
*_override.tf.json
28+
29+
# Include override files you do wish to add to version control using negated pattern
30+
#
31+
# !example_override.tf

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/gruntwork-io/pre-commit
3+
rev: "v0.1.17" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
4+
hooks:
5+
- id: tflint
6+
args:
7+
- --module
8+
- --config=.tflint.hcl
9+
- id: terraform-validate
10+
- id: terraform-fmt
11+
12+
- repo: https://github.com/terraform-docs/terraform-docs
13+
rev: "v0.16.0" # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
14+
hooks:
15+
- id: terraform-docs-go
16+
args: ["."]
17+
18+
- repo: https://github.com/bridgecrewio/checkov.git
19+
rev: "2.2.168" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
20+
hooks:
21+
- id: checkov
22+
23+
- repo: https://github.com/pre-commit/pre-commit-hooks
24+
rev: "v4.3.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
25+
hooks:
26+
- id: check-merge-conflict
27+
- id: end-of-file-fixer

.terraform-docs.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
formatter: "md tbl" # this is required
2+
3+
version: ">= 0.14"
4+
5+
sections:
6+
hide: []
7+
show: [all]
8+
9+
content: |-
10+
{{ .Header }}
11+
12+
{{ .Footer }}
13+
14+
{{ .Inputs }}
15+
16+
{{ .Modules }}
17+
18+
{{ .Outputs }}
19+
20+
{{ .Providers }}
21+
22+
{{ .Requirements }}
23+
24+
{{ .Resources }}
25+
26+
output:
27+
file: "README.md"
28+
mode: inject
29+
template: |-
30+
<!-- BEGIN_TF_DOCS -->
31+
{{ .Content }}
32+
<!-- END_TF_DOCS -->
33+
34+
output-values:
35+
enabled: false
36+
from: ""
37+
38+
sort:
39+
enabled: true
40+
by: name
41+
42+
settings:
43+
anchor: true
44+
color: true
45+
default: true
46+
description: false
47+
escape: true
48+
hide-empty: false
49+
html: true
50+
indent: 2
51+
lockfile: false
52+
read-comments: true
53+
required: true
54+
sensitive: true
55+
type: true

.tflint.hcl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
rule "terraform_deprecated_interpolation" {
2+
enabled = true
3+
}
4+
5+
rule "terraform_documented_outputs" {
6+
enabled = true
7+
}
8+
9+
rule "terraform_documented_variables" {
10+
enabled = true
11+
}
12+
13+
rule "terraform_typed_variables" {
14+
enabled = true
15+
}
16+
17+
rule "terraform_required_version" {
18+
enabled = true
19+
}
20+
21+
rule "terraform_required_providers" {
22+
enabled = true
23+
}
24+
25+
rule "terraform_unused_required_providers" {
26+
enabled = true
27+
}
28+
29+
rule "terraform_naming_convention" {
30+
enabled = true
31+
format = "snake_case"
32+
}

0 commit comments

Comments
 (0)