Skip to content

Commit

Permalink
Merge pull request #24 from clouddrove/1.0.1
Browse files Browse the repository at this point in the history
update github-action
  • Loading branch information
yadavprakash authored Apr 14, 2022
2 parents 82ae1b4 + e362b96 commit 5db377c
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 121 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: 'Create README.md file'
on:
push:
Expand All @@ -19,7 +18,7 @@ jobs:
python-version: '3.x'

- name: 'create readme'
uses: 'clouddrove/github-actions@v8.0'
uses: 'clouddrove/github-actions@v9.0.1'
with:
actions_subcommand: 'readme'
github_token: '${{ secrets.GITHUB}}'
Expand All @@ -36,7 +35,7 @@ jobs:
continue-on-error: true

- name: 'push readme'
uses: 'clouddrove/github-actions@v8.0'
uses: 'clouddrove/github-actions@v9.0.1'
continue-on-error: true
with:
actions_subcommand: 'push'
Expand Down
148 changes: 58 additions & 90 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,47 @@
name: 'Terraform GitHub Actions'
name: static-checks

on:
pull_request:
branches:
- master

jobs:
fmt:
name: 'terraform fmt'
versionExtract:
name: Get min/max versions
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

- name: 'Terraform Format'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'fmt'
- name: 'Terraform Format'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'fmt'

basic_example:
name: 'basic_example'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

- name: 'Configure AWS Credentials'
uses: clouddrove/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
aws-region: us-east-2

- name: 'Terraform init'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/basic_example
- name: Checkout
uses: actions/checkout@v2

- name: 'Terraform validate'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/basic_example
- name: Terraform min/max versions
id: minMax
uses: clowdhaus/terraform-min-max@main
outputs:
minVersion: ${{ steps.minMax.outputs.minVersion }}
maxVersion: ${{ steps.minMax.outputs.maxVersion }}

- name: 'Terraform plan for basic_example'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/basic_example

ebs_mount:
name: 'ebs_mount'
versionEvaluate:
name: Evaluate Terraform versions
runs-on: ubuntu-latest
needs: versionExtract
strategy:
fail-fast: false
matrix:
version:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory:
- _example/basic_example
- _example/ebs_mount

steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4
- name: Checkout
uses: actions/checkout@v2

- name: Install Terraform v${{ matrix.version }}
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ matrix.version }}

- name: 'Configure AWS Credentials'
uses: clouddrove/configure-aws-credentials@v1
Expand All @@ -67,50 +50,35 @@ jobs:
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
aws-region: us-east-2

- name: 'Terraform init for ebs_mount'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/ebs_mount

- name: 'Terraform validate for ebs_mount'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/ebs_mount
- name: Init & validate v${{ matrix.version }}
run: |
cd ${{ matrix.directory }}
terraform init
terraform validate
terraform plan -input=false -no-color
- name: 'Terraform plan for ebs_mount'
uses: 'clouddrove/github-actions@v8.0'
- name: tflint
uses: reviewdog/action-tflint@master
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/ebs_mount

pre-commit:
name: 'Pre-Commit'
needs:
- fmt
- basic_example
- ebs_mount
github_token: ${{ secrets.GITHUB }}
working_directory: ${{ matrix.directory }}
fail_on_error: 'true'
filter_mode: 'nofilter'
flags: '--module'

format:
name: Check code format
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4
needs: versionExtract

- name: 'Install Tflint'
run: |
curl https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
- name: 'Pre-Commit 🔎'
uses: pre-commit/action@v2.0.3
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v2

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
- name: Install Terraform v${{ needs.versionExtract.outputs.maxVersion }}
uses: hashicorp/setup-terraform@v1
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
terraform_version: ${{ needs.versionExtract.outputs.maxVersion }}

- name: Check Terraform format changes
run: terraform fmt --recursive
4 changes: 2 additions & 2 deletions .github/workflows/terratest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: 'Terratest Basic'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v8.0'
uses: 'clouddrove/github-actions@v9.0.1'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/basic_example'
Expand All @@ -32,7 +32,7 @@ jobs:

- name: 'Terratest Secure'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v8.0'
uses: 'clouddrove/github-actions@v9.0.1'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/ebs_mount'
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/tfsec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: tfsec
on:
pull_request:

jobs:
tfsec:
name: tfsec sarif report
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@master

- name: tfsec
uses: aquasecurity/tfsec-sarif-action@v0.1.0
with:
sarif_file: tfsec.sarif
working_directory: _example
full_repo_scan: true

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
with:
# Path to SARIF file relative to the root of the repository
sarif_file: tfsec.sarif
Loading

0 comments on commit 5db377c

Please sign in to comment.