generated from getindata/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fbcd518
Showing
23 changed files
with
1,475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Generate terraform docs | ||
on: | ||
- pull_request | ||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Render terraform docs inside the README.md and push changes back to PR branch | ||
uses: terraform-docs/[email protected] | ||
with: | ||
working-dir: . | ||
config-file: .terraform-docs.yml | ||
git-push: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: 'Validate PR title' | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
main: | ||
name: Validate PR title | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Please look up the latest version from | ||
# https://github.com/amannn/action-semantic-pull-request/releases | ||
- uses: amannn/action-semantic-pull-request@v4 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
# Configure which types are allowed. | ||
# Default: https://github.com/commitizen/conventional-commit-types | ||
types: | | ||
feat | ||
fix | ||
improvement | ||
docs | ||
refactor | ||
test | ||
ci | ||
chore | ||
# Configure that a scope must always be provided. | ||
requireScope: false | ||
# Configure additional validation for the subject based on a regex. | ||
# This example ensures the subject starts with an uppercase character. | ||
subjectPattern: ^[A-Z].+$ | ||
# If `subjectPattern` is configured, you can use this property to override | ||
# the default error message that is shown when the pattern doesn't match. | ||
# The variables `subject` and `title` can be used within the message. | ||
subjectPatternError: | | ||
The subject "{subject}" found in the pull request title "{title}" | ||
didn't match the configured pattern. Please ensure that the subject | ||
starts with an uppercase character. | ||
# For work-in-progress PRs you can typically use draft pull requests | ||
# from Github. However, private repositories on the free plan don't have | ||
# this option and therefore this action allows you to opt-in to using the | ||
# special "[WIP]" prefix to indicate this state. This will avoid the | ||
# validation of the PR title and the pull request checks remain pending. | ||
# Note that a second check will be reported if this is enabled. | ||
wip: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Pre-Commit | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
|
||
env: | ||
TERRAFORM_DOCS_VERSION: v0.16.0 | ||
|
||
jobs: | ||
collectInputs: | ||
name: Collect workflow inputs | ||
runs-on: ubuntu-latest | ||
outputs: | ||
directories: ${{ steps.dirs.outputs.directories }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get root directories | ||
id: dirs | ||
uses: clowdhaus/terraform-composite-actions/[email protected] | ||
|
||
preCommitMinVersions: | ||
name: Min TF pre-commit | ||
needs: collectInputs | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Terraform min/max versions | ||
id: minMax | ||
uses: clowdhaus/[email protected] | ||
with: | ||
directory: ${{ matrix.directory }} | ||
|
||
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} | ||
# Run only validate pre-commit check on min version supported | ||
if: ${{ matrix.directory != '.' }} | ||
uses: clowdhaus/terraform-composite-actions/[email protected] | ||
with: | ||
terraform-version: ${{ steps.minMax.outputs.minVersion }} | ||
args: 'terraform-validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' | ||
|
||
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} | ||
# Run only validate pre-commit check on min version supported | ||
if: ${{ matrix.directory == '.' }} | ||
uses: clowdhaus/terraform-composite-actions/[email protected] | ||
with: | ||
terraform-version: ${{ steps.minMax.outputs.minVersion }} | ||
args: 'terraform-validate --color=always --show-diff-on-failure --files $(ls *.tf)' | ||
|
||
preCommitMaxVersion: | ||
name: Max TF pre-commit | ||
runs-on: ubuntu-latest | ||
needs: collectInputs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
|
||
- name: Terraform min/max versions | ||
id: minMax | ||
uses: clowdhaus/[email protected] | ||
|
||
# Step required as tflint pre-commit hook requires module to be initialised | ||
- run: terraform init | ||
|
||
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} | ||
uses: clowdhaus/terraform-composite-actions/[email protected] | ||
with: | ||
terraform-version: ${{ steps.minMax.outputs.maxVersion }} | ||
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Create new release with changelog | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 100 | ||
|
||
- name: Check release label | ||
id: release-label | ||
uses: actions-ecosystem/action-release-label@v1 | ||
if: ${{ github.event.pull_request.merged == true }} | ||
|
||
- name: Get latest tag | ||
id: get-latest-tag | ||
uses: actions-ecosystem/action-get-latest-tag@v1 | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
|
||
- name: Bump semantic version | ||
id: bump-semver | ||
uses: actions-ecosystem/action-bump-semver@v1 | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
with: | ||
current_version: ${{ steps.get-latest-tag.outputs.tag }} | ||
level: ${{ steps.release-label.outputs.level }} | ||
|
||
- name: Tag release | ||
id: tag-relese | ||
uses: actions-ecosystem/action-push-tag@v1 | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
with: | ||
tag: ${{ steps.bump-semver.outputs.new_version }} | ||
message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}" | ||
|
||
- name: Generate new release with changelog | ||
id: release-with-changelog | ||
uses: fregante/release-with-changelog@v3 | ||
if: ${{ steps.bump-semver.outputs.new_version != null }} | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
exclude: '^meta|^docs|^document|^lint|^ci|^refactor|readme|workflow|bump|dependencies|yml|^v?\d+\.\d+\.\d+' | ||
tag: "${{ steps.bump-semver.outputs.new_version }}" | ||
title: "Version ${{ steps.bump-semver.outputs.new_version }}" | ||
commit-template: "- {title} ← {hash}" | ||
skip-on-empty: true | ||
template: | | ||
### Changelog | ||
{commits} | ||
{range} | ||
- name: Comment PR | ||
id: add-comment | ||
uses: actions-ecosystem/action-create-comment@v1 | ||
if: ${{ steps.bump-semver.outputs.new_version != null }} | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
number: ${{ steps.get-merged-pull-request.outputs.number }} | ||
body: | | ||
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Terraform template | ||
# Local .terraform directories | ||
.terraform | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# terraform.lock.hcl files | ||
.terraform.lock.hcl | ||
|
||
# Exclude all .tfvars files, which are likely to contain sentitive data, such as | ||
# password, private keys, and other secrets. These should not be part of version | ||
# control as they are data points which are potentially sensitive and subject | ||
# to change depending on the environment. | ||
# | ||
terraform.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Include override files you do wish to add to version control using negated pattern | ||
# | ||
# !example_override.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
repos: | ||
- repo: https://github.com/gruntwork-io/pre-commit | ||
rev: "v0.1.17" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases | ||
hooks: | ||
- id: tflint | ||
args: | ||
- --module | ||
- --config=.tflint.hcl | ||
- id: terraform-validate | ||
- id: terraform-fmt | ||
|
||
- repo: https://github.com/terraform-docs/terraform-docs | ||
rev: "v0.16.0" # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases | ||
hooks: | ||
- id: terraform-docs-go | ||
args: ["."] | ||
|
||
- repo: https://github.com/bridgecrewio/checkov.git | ||
rev: '2.0.1161' # Get the latest from: https://github.com/bridgecrewio/checkov/releases | ||
hooks: | ||
- id: checkov | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: "v4.3.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
formatter: "md tbl" # this is required | ||
|
||
version: ">= 0.14" | ||
|
||
sections: | ||
hide: [] | ||
show: [all] | ||
|
||
content: |- | ||
{{ .Header }} | ||
{{ .Footer }} | ||
{{ .Inputs }} | ||
{{ .Modules }} | ||
{{ .Outputs }} | ||
{{ .Providers }} | ||
{{ .Requirements }} | ||
{{ .Resources }} | ||
output: | ||
file: "README.md" | ||
mode: inject | ||
template: |- | ||
<!-- BEGIN_TF_DOCS --> | ||
{{ .Content }} | ||
<!-- END_TF_DOCS --> | ||
output-values: | ||
enabled: false | ||
from: "" | ||
|
||
sort: | ||
enabled: true | ||
by: name | ||
|
||
settings: | ||
anchor: true | ||
color: true | ||
default: true | ||
description: false | ||
escape: true | ||
hide-empty: false | ||
html: true | ||
indent: 2 | ||
lockfile: false | ||
read-comments: true | ||
required: true | ||
sensitive: true | ||
type: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
rule "terraform_deprecated_interpolation" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_documented_outputs" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_documented_variables" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_typed_variables" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_required_version" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_required_providers" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_unused_required_providers" { | ||
enabled = true | ||
} | ||
|
||
rule "terraform_naming_convention" { | ||
enabled = true | ||
format = "snake_case" | ||
} |
Oops, something went wrong.