Skip to content

Commit 2caa958

Browse files
committed
[autoSync] CI: support commitlint check
1 parent af43b26 commit 2caa958

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

.github/workflows/e2e.yml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,46 @@ on:
55
- master
66
- main
77
types: [ 'opened', 'synchronize' ]
8-
paths:
9-
- '.github/**'
10-
- '.github/workflows/**'
11-
- '**/*.tf'
128

139
jobs:
10+
commitlint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: ahmadnassri/action-commit-lint@v2
14+
15+
changes-files:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
changed_files_list: ${{ steps.changed-files.outputs.all_changed_files }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Get changed files
22+
id: changed-files
23+
uses: tj-actions/changed-files@v34
24+
with:
25+
separator: ","
26+
1427
terraform-fmt:
1528
runs-on: ubuntu-latest
29+
needs: changes-files
30+
if: contains(needs.changes-files.outputs.changed_files_list, '.tf')
1631
steps:
17-
- name: checkout
18-
uses: actions/checkout@v3
19-
- name: fmt-check
20-
run: |
21-
if [ ! -f /usr/local/bin/terraform ]; then
22-
wget -q https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
23-
unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
24-
fi
25-
error=false
26-
echo "===> Terraform fmt -diff checking"
27-
terraform fmt -diff -recursive -check
28-
if [[ $? -ne 0 ]]; then
29-
echo -e "\033[31m[ERROR]\033[0m: Some codes has not been formatted, and please running terraform fmt --recursive command before pushing."
30-
exit 1
31-
fi
32+
- uses: actions/checkout@v4
33+
- uses: hashicorp/setup-terraform@v3
34+
- name: Terraform fmt
35+
id: fmt
36+
run: terraform fmt -check -recursive
3237

3338
terraform-validate:
3439
runs-on: ubuntu-latest
40+
needs: changes-files
41+
if: contains(needs.changes-files.outputs.changed_files_list, '.tf')
3542
steps:
3643
- name: checkout
3744
uses: actions/checkout@v3
45+
- uses: hashicorp/setup-terraform@v3
3846
- name: validate-check
3947
run: |
40-
if [ ! -f /usr/local/bin/terraform ]; then
41-
wget -q https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
42-
unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
43-
fi
4448
exp="examples"
4549
output_file="combined_output.txt"
4650
if [[ -d "$exp" ]]; then
@@ -63,6 +67,8 @@ jobs:
6367
6468
tflint:
6569
runs-on: ubuntu-latest
70+
needs: changes-files
71+
if: contains(needs.changes-files.outputs.changed_files_list, '.tf')
6672
steps:
6773
- name: checkout
6874
uses: actions/checkout@v3
@@ -105,7 +111,6 @@ jobs:
105111
fi
106112
107113
e2e-check:
108-
# if: github.event.review.state == 'approved' || github.event.review.body == 'approved'
109114
needs: [terraform-fmt, terraform-validate, tflint]
110115
runs-on: ubuntu-latest
111116
name: 'e2e check'

0 commit comments

Comments
 (0)