Skip to content

Commit 808c371

Browse files
authored
ci: overhaul workflows (#22)
1 parent 8bce581 commit 808c371

22 files changed

+1432
-136
lines changed

.github/auto-release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ categories:
3434
- 'feat'
3535
- title: '🐛 Bug Fixes'
3636
labels:
37-
- 'auto-update'
3837
- 'patch'
3938
- 'fix'
4039
- 'bugfix'
4140
- 'bug'
4241
- 'hotfix'
4342
- 'refactor'
44-
- 'ci'
45-
- 'build'
4643
- 'docs'
4744
- 'test'
4845
- 'chore'
49-
- title: '🤖 Automatic Updates'
46+
- title: '📦 Updates'
5047
labels:
5148
- 'auto-update'
49+
- 'build'
50+
- 'ci'
51+
- title: ':hammer_and_wrench: Refactoring'
52+
labels:
53+
- 'refactor'
5254

5355
change-template: |
5456
<details>

.github/dependabot.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@ updates:
55
schedule:
66
interval: "weekly"
77
labels:
8-
- "chore"
8+
- ci
9+
commit-message:
10+
prefix: "[skip-release] ci:"
911
- package-ecosystem: "terraform"
1012
directory: "/"
1113
schedule:
1214
interval: "weekly"
1315
labels:
14-
- "chore"
16+
- build
17+
commit-message:
18+
prefix: "build:"
19+
- package-ecosystem: "gomod"
20+
directory: "/"
21+
schedule:
22+
interval: "weekly"
23+
labels:
24+
- build
25+
commit-message:
26+
prefix: "[skip-release] build:"

.github/workflows/ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Validate and Test Terraform manifests
2+
3+
on:
4+
pull_request:
5+
6+
env:
7+
TERRAFORM_VERSION: ~1.9
8+
9+
jobs:
10+
terraform:
11+
name: terraform
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Terraform
18+
uses: hashicorp/setup-terraform@v3
19+
with:
20+
terraform_version: ${{ env.TERRAFORM_VERSION }}
21+
22+
- name: Ensure Terraform code is formated
23+
run: terraform fmt -check
24+
25+
- name: Terraform Init
26+
run: terraform init
27+
28+
- name: Validate Terraform code
29+
run: terraform validate -no-color
30+
31+
trivy:
32+
name: trivy
33+
runs-on: ubuntu-latest
34+
needs: terraform
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Terraform
40+
uses: hashicorp/setup-terraform@v3
41+
with:
42+
terraform_version: ${{ env.TERRAFORM_VERSION }}
43+
44+
- name: Terraform Init
45+
run: terraform init
46+
47+
- name: Run trivy with reviewdog output on the PR
48+
uses: reviewdog/action-trivy@v1
49+
with:
50+
trivy_command: config
51+
trivy_target: .
52+
github_token: ${{ secrets.github_token }}
53+
reporter: github-pr-review
54+
filter_mode: diff_context
55+
fail_on_error: "true"
56+
57+
tflint:
58+
name: tflint
59+
runs-on: ubuntu-latest
60+
needs: terraform
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v4
64+
65+
- name: Setup Terraform
66+
uses: hashicorp/setup-terraform@v3
67+
with:
68+
terraform_version: ${{ env.TERRAFORM_VERSION }}
69+
70+
- name: Terraform Init
71+
run: terraform init
72+
73+
- name: Check with tflint
74+
uses: reviewdog/action-tflint@v1
75+
with:
76+
github_token: ${{ secrets.github_token }}
77+
reporter: github-pr-review
78+
fail_on_error: "true"
79+
filter_mode: diff_context
80+
flags: "--module"
81+
82+
terratest:
83+
name: terratest
84+
runs-on: ubuntu-latest
85+
needs:
86+
- terraform
87+
- trivy
88+
- tflint
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
93+
- name: Setup Terraform
94+
uses: hashicorp/setup-terraform@v3
95+
with:
96+
terraform_version: ${{ env.TERRAFORM_VERSION }}
97+
98+
- name: Setup go
99+
uses: actions/setup-go@v5
100+
with:
101+
go-version-file: tests/go.mod
102+
cache-dependency-path: |
103+
tests/go.sum
104+
105+
- name: Run terratest
106+
run: make terratest

.github/workflows/docs.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,8 @@ jobs:
1111
with:
1212
ref: ${{ github.event.pull_request.head.ref }}
1313

14-
- name: Render terraform docs inside the examples/basic/README.md
14+
- name: Render terraform docs
1515
uses: terraform-docs/gh-actions@v1.2.0
1616
with:
17-
working-dir: ./examples/basic/
18-
git-push: "false"
19-
output-file: README.md
20-
config-file: ./examples/basic/.terraform-docs.yml
21-
22-
- name: Render terraform docs inside the README.md
23-
uses: terraform-docs/gh-actions@v1.2.0
24-
with:
25-
working-dir: .
17+
working-dir: .,./examples/basic
2618
git-push: "true"
27-
output-file: README.md

.github/workflows/labeler.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/pr-lint.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
jobs:
1111
lint-pr:
1212
runs-on: ubuntu-latest
13-
1413
steps:
1514
- name: Lint PR
1615
uses: amannn/action-semantic-pull-request@v5
@@ -50,3 +49,10 @@ jobs:
5049
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
5150
* **test**: Adding missing tests or correcting existing tests
5251
* **chore**: No production code change
52+
53+
- name: Add label to PR
54+
if: github.actor != 'dependabot[bot]'
55+
uses: fuxingloh/multi-labeler@v4.0.0
56+
with:
57+
github-token: ${{ secrets.GITHUB_TOKEN }}
58+
config-path: .github/labeler.yml

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ jobs:
99
publish:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: release-drafter/release-drafter@v6
12+
- name: Create Release
13+
if: "!contains(github.event.head_commit.message, '[skip-release]')"
14+
uses: release-drafter/release-drafter@v6
1315
with:
1416
publish: true
1517
prerelease: false

.github/workflows/stale.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
jobs:
88
stale:
99
runs-on: ubuntu-latest
10-
1110
steps:
12-
- uses: actions/stale@v9
11+
- name: Run stale actio
12+
uses: actions/stale@v9
1313
with:
1414
repo-token: ${{ secrets.GITHUB_TOKEN }}
1515
stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days"

.github/workflows/terraform.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/tflint.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)