Skip to content

Commit d95e1db

Browse files
authored
Merge pull request #28 from clouddrove/1.0.1
Add github-action
2 parents d5a229d + 41eb6a8 commit d95e1db

File tree

12 files changed

+337
-110
lines changed

12 files changed

+337
-110
lines changed

.github/workflows/readme.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python-version: '3.x'
1919

2020
- name: 'create readme'
21-
uses: 'clouddrove/github-actions@v9.0.1'
21+
uses: 'clouddrove/github-actions@v9.0.2'
2222
with:
2323
actions_subcommand: 'readme'
2424
github_token: '${{ secrets.GITHUB}}'
@@ -35,7 +35,7 @@ jobs:
3535
continue-on-error: true
3636

3737
- name: 'push readme'
38-
uses: 'clouddrove/github-actions@v9.0.1'
38+
uses: 'clouddrove/github-actions@v9.0.2'
3939
continue-on-error: true
4040
with:
4141
actions_subcommand: 'push'

.github/workflows/terraform.yml

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,85 @@
1-
name: 'Terraform GitHub Actions'
1+
name: static-checks
2+
23
on:
34
pull_request:
4-
branches:
5-
- master
65

76
jobs:
8-
terraform:
9-
name: 'Terraform'
7+
versionExtract:
8+
name: Get min/max versions
109
runs-on: ubuntu-latest
10+
1111
steps:
12-
- name: 'Checkout'
13-
uses: actions/checkout@master
12+
- name: Checkout
13+
uses: actions/checkout@v2
1414

15-
- name: Configure AWS Credentials
16-
uses: clouddrove/configure-aws-credentials@v1
17-
with:
18-
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
19-
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
20-
aws-region: us-east-2
15+
- name: Terraform min/max versions
16+
id: minMax
17+
uses: clowdhaus/terraform-min-max@main
18+
outputs:
19+
minVersion: ${{ steps.minMax.outputs.minVersion }}
20+
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
2121

22-
- name: 'Terraform Format'
23-
uses: 'clouddrove/github-actions@v9.0.1'
24-
with:
25-
actions_subcommand: 'fmt'
2622

27-
- name: 'Terraform init for memcached'
28-
uses: 'clouddrove/github-actions@v9.0.1'
29-
with:
30-
actions_subcommand: 'init'
31-
tf_actions_working_dir: ./_example/memcached
23+
versionEvaluate:
24+
name: Evaluate Terraform versions
25+
runs-on: ubuntu-latest
26+
needs: versionExtract
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
version:
31+
- ${{ needs.versionExtract.outputs.minVersion }}
32+
- ${{ needs.versionExtract.outputs.maxVersion }}
33+
directory:
34+
- _example/memcached
35+
- _example/redis
36+
- _example/redis-cluster
3237

33-
- name: 'Terraform validate for memcached'
34-
uses: 'clouddrove/github-actions@v9.0.1'
35-
with:
36-
actions_subcommand: 'validate'
37-
tf_actions_working_dir: ./_example/memcached
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v2
3841

39-
- name: 'Terraform plan for memcached'
40-
uses: 'clouddrove/github-actions@v9.0.1'
42+
- name: Install Terraform v${{ matrix.version }}
43+
uses: hashicorp/setup-terraform@v1
4144
with:
42-
actions_subcommand: 'plan'
43-
tf_actions_working_dir: ./_example/memcached
45+
terraform_version: ${{ matrix.version }}
4446

45-
- name: 'Terraform init for redis'
46-
uses: 'clouddrove/github-actions@v9.0.1'
47+
- name: 'Configure AWS Credentials'
48+
uses: clouddrove/configure-aws-credentials@v1
4749
with:
48-
actions_subcommand: 'init'
49-
tf_actions_working_dir: ./_example/redis
50+
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
51+
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
52+
aws-region: us-east-2
5053

51-
- name: 'Terraform validate for redis'
52-
uses: 'clouddrove/github-actions@v9.0'
53-
with:
54-
actions_subcommand: 'validate'
55-
tf_actions_working_dir: ./_example/redis
54+
- name: Init & validate v${{ matrix.version }}
55+
run: |
56+
cd ${{ matrix.directory }}
57+
terraform init
58+
terraform validate
59+
terraform plan -input=false -no-color
5660
57-
- name: 'Terraform plan for redis'
58-
uses: 'clouddrove/github-actions@v9.0.1'
61+
- name: tflint
62+
uses: reviewdog/action-tflint@master
5963
with:
60-
actions_subcommand: 'plan'
61-
tf_actions_working_dir: ./_example/redis
64+
github_token: ${{ secrets.GITHUB }}
65+
working_directory: ${{ matrix.directory }}
66+
fail_on_error: 'true'
67+
filter_mode: 'nofilter'
68+
flags: '--module'
6269

63-
- name: 'Terraform init for redis-cluster'
64-
uses: 'clouddrove/github-actions@v9.0.1'
65-
with:
66-
actions_subcommand: 'init'
67-
tf_actions_working_dir: ./_example/redis-cluster
70+
format:
71+
name: Check code format
72+
runs-on: ubuntu-latest
73+
needs: versionExtract
6874

69-
- name: 'Terraform validate for redis-cluster'
70-
uses: 'clouddrove/github-actions@v9.0.1'
71-
with:
72-
actions_subcommand: 'validate'
73-
tf_actions_working_dir: ./_example/redis-cluster
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v2
7478

75-
- name: 'Terraform plan for redis-cluster'
76-
uses: 'clouddrove/github-actions@v9.0.1'
79+
- name: Install Terraform v${{ needs.versionExtract.outputs.maxVersion }}
80+
uses: hashicorp/setup-terraform@v1
7781
with:
78-
actions_subcommand: 'plan'
79-
tf_actions_working_dir: ./_example/redis-cluster
82+
terraform_version: ${{ needs.versionExtract.outputs.maxVersion }}
8083

81-
82-
- name: 'Slack Notification'
83-
uses: clouddrove/action-slack@v2
84-
with:
85-
status: ${{ job.status }}
86-
fields: repo,author
87-
author_name: 'CloudDrove'
88-
env:
89-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
90-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
91-
if: always()
84+
- name: Check Terraform format changes
85+
run: terraform fmt --recursive

.github/workflows/terratest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: 'Terratest for redis'
2626
if: ${{ github.event.label.name == 'terratest' }}
27-
uses: 'clouddrove/github-actions@v9.0.1'
27+
uses: 'clouddrove/github-actions@v9.0.2'
2828
with:
2929
actions_subcommand: 'terratest'
3030
tf_actions_working_dir: '_test/redis'
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: 'Terratest for redis-cluster'
3535
if: ${{ github.event.label.name == 'terratest' }}
36-
uses: 'clouddrove/github-actions@v9.0.1'
36+
uses: 'clouddrove/github-actions@v9.0.2'
3737
with:
3838
actions_subcommand: 'terratest'
3939
tf_actions_working_dir: '_test/redis-cluster'

.github/workflows/tfsec.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: tfsec
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
tfsec:
7+
name: tfsec sarif report
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Clone repo
12+
uses: actions/checkout@master
13+
14+
- name: tfsec
15+
uses: aquasecurity/tfsec-sarif-action@v0.1.0
16+
with:
17+
sarif_file: tfsec.sarif
18+
working_directory: _example
19+
full_repo_scan: true
20+
21+
- name: Upload SARIF file
22+
uses: github/codeql-action/upload-sarif@v1
23+
with:
24+
# Path to SARIF file relative to the root of the repository
25+
sarif_file: tfsec.sarif

0 commit comments

Comments
 (0)