Skip to content

Commit

Permalink
pre-setup terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
petretiandrea committed Oct 17, 2024
1 parent 938438e commit 2b88dbc
Show file tree
Hide file tree
Showing 9 changed files with 549 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/pr-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Validate PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-22.04
steps:
# Please look up the latest version from
# https://github.com/amannn/action-semantic-pull-request/releases
# from https://github.com/amannn/action-semantic-pull-request/commits/main
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed.
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
chore
breaking
# 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: ^.+$
# 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
# When using "Squash and merge" on a PR with only one commit, GitHub
# will suggest using that commit message instead of the PR title for the
# merge commit, and it's easy to commit this by mistake. Enable this option
# to also validate the commit message for one commit PRs.
validateSingleCommit: false
# Related to `validateSingleCommit` you can opt-in to validate that the PR
# title matches a single commit to avoid confusion.
validateSingleCommitMatchesPrTitle: false
16 changes: 16 additions & 0 deletions .github/workflows/static-analysis-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Static Analysis PR

on:
push:
branches-ignore:
- main

jobs:
static_analysis:
runs-on: ubuntu-22.04

steps:
- name: Static Analysis
uses: pagopa/eng-github-actions-iac-template/azure/terraform-static-analysis@1e65ac158f5f60d3e46d3621dd4321f7b6e2d80d # v1.8.0
with:
precommit_version: 'v1.86.0@sha256:fed35dd9347aa3dd3e59a870dbc4500245dae26910d84065a6f66fe61afceaa8'
16 changes: 16 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Static Analysis

on:
push:
branches:
- main

jobs:
static_analysis:
runs-on: ubuntu-22.04

steps:
- name: Static Analysis
uses: pagopa/eng-github-actions-iac-template/azure/terraform-static-analysis@1e65ac158f5f60d3e46d3621dd4321f7b6e2d80d # v1.8.0
with:
precommit_version: 'v1.86.0@sha256:fed35dd9347aa3dd3e59a870dbc4500245dae26910d84065a6f66fe61afceaa8'
23 changes: 23 additions & 0 deletions .github/workflows/validate-openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run Spectral on Pull Requests

on:
pull_request:
paths:
- 'openapi/**/*.yaml'
- 'openapi/**/*.yml'

permissions:
pull-requests: write

jobs:
build:
name: Run Spectral
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Run Spectral
- uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83 #v0.8.11
with:
file_glob: 'openapi/**/(*.yaml|*.yml)'
repo_token: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
.vscode

# Local .terraform directories
**/.terraform/*

# tfplan files
**/tfplan

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.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

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

*.DS_Store
*.log
.idea
.vscode
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.86.0
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- markdown --sort-by required
- id: terraform_tfsec
- id: terraform_validate
args:
- --init-args=-lockfile=readonly
- --args=-json
- --args=-no-color
1 change: 1 addition & 0 deletions .terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.8.5
Loading

0 comments on commit 2b88dbc

Please sign in to comment.