File tree Expand file tree Collapse file tree 8 files changed +186
-94
lines changed
Expand file tree Collapse file tree 8 files changed +186
-94
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11name : ' Validate PR title'
22
33on :
4- pull_request_target :
5- types :
6- - opened
7- - edited
8- - synchronize
4+ workflow_call :
95
106jobs :
117 main :
Original file line number Diff line number Diff line change 11name : ' Module Release'
22
33on :
4- push :
5- branches :
6- - main
4+ workflow_call :
75
86defaults :
97 run :
@@ -15,10 +13,10 @@ jobs:
1513 runs-on : ubuntu-latest
1614 steps :
1715 - name : Checkout
18- uses : actions/checkout@v2
19- with :
20- persist-credentials : false
21- fetch-depth : 0
16+ uses : actions/checkout@v4
17+
18+ - name : Git pull
19+ run : git pull origin main
2220
2321 - name : Release
2422 uses : cycjimmy/semantic-release-action@v2
Original file line number Diff line number Diff line change 1- name : Pre-Commit
1+ name : Terraform Checks
22
33on :
4- push :
5- branches :
6- - main
7- - master
8- pull_request :
9- branches :
10- - main
11- - master
4+ workflow_call :
125
136env :
14- TERRAFORM_DOCS_VERSION : v0.16 .0
15- TFLINT_VERSION : v0.50.3
7+ TERRAFORM_DOCS_VERSION : v0.18 .0
8+ TFLINT_VERSION : v0.52.0
169
1710jobs :
11+ test :
12+ name : Test
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Setup Terraform
16+ uses : hashicorp/setup-terraform@v3
17+ with :
18+ terraform_version : " 1.8.4"
19+
20+ - name : Initialize Terraform
21+ id : init
22+ run : terraform init -input=false
23+
24+ - name : Terraform Test
25+ id : fmt
26+ run : terraform test
27+
1828 collectInputs :
1929 name : Collect workflow inputs
30+ needs : test
2031 runs-on : ubuntu-latest
2132 outputs :
2233 directories : ${{ steps.dirs.outputs.directories }}
Original file line number Diff line number Diff line change 1+ name : Terraform Docs
2+
3+ on :
4+ workflow_call :
5+
6+ env :
7+ TERRAFORM_DOCS_VERSION : v0.18.0
8+
9+ jobs :
10+ generateDocs :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+ with :
16+ ref : ${{ github.ref }}
17+
18+ - name : Render and Push terraform docs for main module
19+ uses : terraform-docs/gh-actions@main
20+ with :
21+ working-dir : .
22+ git-push : true
23+ output-file : README.md
24+ output-format : markdown table
25+ output-method : replace
26+ recursive : false
27+ template : |
28+ <!-- BEGIN_TF_DOCS -->
29+ {{ .Content }}
30+ <!-- END_TF_DOCS -->
31+ {{- printf "\n" -}}
32+ args : " --header-from .header.md"
33+
34+ - name : Check if modules folder exists
35+ id : check_modules
36+ run : echo "modules_exists=$(if [ -d modules ]; then echo true; else echo false; fi)" >> $GITHUB_ENV
37+
38+ - name : Render and Push terraform docs for sub modules
39+ if : env.modules_exists == 'true'
40+ uses : terraform-docs/gh-actions@main
41+ with :
42+ working-dir : .
43+ git-push : true
44+ output-file : README.md
45+ output-format : markdown table
46+ output-method : replace
47+ recursive : true
48+ recursive-path : modules
49+ template : |
50+ <!-- BEGIN_TF_DOCS -->
51+ {{ .Content }}
52+ <!-- END_TF_DOCS -->
53+ {{- printf "\n" -}}
54+ args : " --header-from .header.md"
55+
56+
57+ - name : Check if examples folder exists
58+ id : check_examples
59+ run : echo "examples_exists=$(if [ -d examples ]; then echo true; else echo false; fi)" >> $GITHUB_ENV
60+
61+ - name : Render and Push terraform docs for examples
62+ if : env.examples_exists == 'true'
63+ uses : terraform-docs/gh-actions@main
64+ with :
65+ working-dir : .
66+ git-push : true
67+ output-file : README.md
68+ output-format : markdown table
69+ output-method : replace
70+ recursive : true
71+ recursive-path : examples
72+ template : |
73+ <!-- BEGIN_TF_DOCS -->
74+ {{ .Content }}
75+ <!-- END_TF_DOCS -->
76+ {{- printf "\n" -}}
77+ args : " --header-from .header.md"
Original file line number Diff line number Diff line change 1+ name : Terraform Master Workflow
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - master
8+ pull_request_target :
9+ types :
10+ - opened
11+ - edited
12+ - synchronize
13+ pull_request :
14+ branches :
15+ - main
16+ - master
17+ jobs :
18+ prTitlecheck :
19+ name : PR title check
20+ if : ${{ github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main' }}
21+ uses : ./.github/workflows/pr-title.yaml
22+
23+ preCommitCheck :
24+ name : Terraform Checks
25+ uses : ./.github/workflows/terraform-checks.yaml
26+
27+ generateDocs :
28+ name : Generate Terraform Docs
29+ needs : preCommitCheck
30+ uses : ./.github/workflows/terraform-docs.yaml
31+
32+ release :
33+ name : Release module
34+ needs : generateDocs
35+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
36+ uses : ./.github/workflows/release.yaml
Original file line number Diff line number Diff line change 1+ name : Update Configuration from Template
2+
3+ on :
4+ workflow_dispatch :
5+
6+ jobs :
7+ update :
8+ runs-on : ubuntu-latest
9+
10+ steps :
11+ - name : Checkout template repository
12+ uses : actions/checkout@v3
13+ with :
14+ repository : nimisha-gj/terraform-module-template
15+ token : ${{ secrets.GITHUB_TOKEN }}
16+ path : template-repo
17+
18+ - name : Checkout target repository
19+ uses : actions/checkout@v3
20+ with :
21+ repository : ${{ github.repository }}
22+ token : ${{ secrets.GITHUB_TOKEN }}
23+ path : target-repo
24+
25+ - name : Set up Git
26+ run : |
27+ git config --global user.name "github-actions"
28+ git config --global user.email "[email protected] " 29+
30+ - name : Copy files from template repository
31+ run : |
32+ cp template-repo/.editorconfig target-repo/
33+ cp template-repo/.pre-commit-config.yaml target-repo/
34+ cp template-repo/LICENSE target-repo/
35+ cp template-repo/.tflint.hcl target-repo/
36+ cp template-repo/.releaserc.json target-repo/
37+ cp template-repo/CODE_OF_CONDUCT.md target-repo/
38+ cp template-repo/CONTRIBUTING.md target-repo/
39+
40+ - name : Commit and push changes
41+ run : |
42+ cd target-repo
43+ git add .
44+ git commit -m "Update files from terraform-module-template"
45+ git push
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments