Skip to content

Commit e403997

Browse files
authored
ci: overhaul workflows (#9)
1 parent f4a4253 commit e403997

25 files changed

+1768
-169
lines changed

.github/auto-release.yml

+6-4
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

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- ci
9+
commit-message:
10+
prefix: "[skip-release] ci:"
11+
- package-ecosystem: "terraform"
12+
directory: "/"
13+
schedule:
14+
interval: "weekly"
15+
labels:
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/labels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
description: Adding missing tests or correcting existing tests
5555
- color: dfb443
5656
name: chore
57-
description: Adding missing tests or correcting existing tests
57+
description: Adding missing tests or correcting existing tests

.github/workflows/ci.yml

+106
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

+5-22
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,13 @@ jobs:
66
docs:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
9+
- name: Checkout
10+
uses: actions/checkout@v4
1011
with:
1112
ref: ${{ github.event.pull_request.head.ref }}
1213

13-
- name: Render terraform docs inside the examples/basic/README.md
14-
uses: terraform-docs/gh-actions@v1.0.0
14+
- name: Render terraform docs
15+
uses: terraform-docs/gh-actions@v1.2.0
1516
with:
16-
working-dir: ./examples/basic/
17-
git-push: "false"
18-
output-file: README.md
19-
config-file: ".terraform-docs.yml"
20-
21-
- name: Render terraform docs inside the examples/basic/README.md
22-
uses: terraform-docs/[email protected]
23-
with:
24-
working-dir: ./examples/replicated/
25-
git-push: "false"
26-
output-file: README.md
27-
config-file: ".terraform-docs.yml"
28-
29-
- name: Render terraform docs inside the README.md
30-
uses: terraform-docs/[email protected]
31-
with:
32-
working-dir: .
17+
working-dir: .,./examples/basic,./examples/replicated
3318
git-push: "true"
34-
output-file: README.md
35-
config-file: ".terraform-docs.yml"

.github/workflows/labeler.yml

-14
This file was deleted.

.github/workflows/labels.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
---
21
name: Sync labels
32

43
on:
54
push:
65
branches:
7-
- master
86
- main
7+
pull_request:
8+
paths:
9+
- ".github/labels.yml"
10+
- ".github/workflows/labels.yml"
911

1012
jobs:
1113
sync-labels:
1214
name: Sync labels in the declarative way
1315
runs-on: ubuntu-latest
1416
steps:
15-
- uses: actions/checkout@v3
16-
- uses: micnncim/[email protected]
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
GITHUB_REPOSITORY: ${{ github.repository }}
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Sync labels
21+
uses: crazy-max/ghaction-github-labeler@v5
2022
with:
21-
manifest: .github/labels.yml
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
yaml-file: .github/labels.yml
25+
dry-run: ${{ github.event_name == 'pull_request' }}

.github/workflows/pr-lint.yml

+21-5
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,34 @@ on:
44
pull_request_target:
55
types:
66
- opened
7-
- reopened
87
- edited
98
- synchronize
109

1110
jobs:
1211
lint-pr:
1312
runs-on: ubuntu-latest
14-
1513
steps:
1614
- name: Lint PR
17-
uses: aslafy-z/[email protected]
15+
uses: amannn/action-semantic-pull-request@v5
1816
with:
19-
preset: conventional-changelog-angular@^5.0.6
17+
types: |
18+
build
19+
ci
20+
docs
21+
feat
22+
fix
23+
perf
24+
refactor
25+
style
26+
test
27+
chore
28+
requireScope: false
2029
env:
2130
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2231

2332
- name: Comment for PR title conformance
2433
if: failure()
25-
uses: peter-evans/create-or-update-comment@v3
34+
uses: peter-evans/create-or-update-comment@v4
2635
with:
2736
issue-number: ${{tojson(github.event.number)}}
2837
body: |
@@ -40,3 +49,10 @@ jobs:
4049
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
4150
* **test**: Adding missing tests or correcting existing tests
4251
* **chore**: No production code change
52+
53+
- name: Add label to PR
54+
if: github.actor != 'dependabot[bot]'
55+
uses: fuxingloh/[email protected]
56+
with:
57+
github-token: ${{ secrets.GITHUB_TOKEN }}
58+
config-path: .github/labeler.yml

.github/workflows/release.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ name: Release Drafter
33
on:
44
push:
55
branches:
6-
- master
76
- main
87

98
jobs:
109
publish:
1110
runs-on: ubuntu-latest
1211
steps:
13-
- uses: release-drafter/release-drafter@v5
12+
- name: Create Release
13+
if: "!contains(github.event.head_commit.message, '[skip-release]')"
14+
uses: release-drafter/release-drafter@v6
1415
with:
1516
publish: true
1617
prerelease: false

.github/workflows/stale.yml

+2-2
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@v8
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

-26
This file was deleted.

.github/workflows/tflint.yml

-29
This file was deleted.

0 commit comments

Comments
 (0)