Skip to content

Commit c9e282b

Browse files
authored
fix: update CI/CD process to enable auto-release workflow (#51)
1 parent bf1d244 commit c9e282b

File tree

13 files changed

+134
-222
lines changed

13 files changed

+134
-222
lines changed

.chglog/CHANGELOG.tpl.md

-111
This file was deleted.

.chglog/config.yml

-10
This file was deleted.

.github/workflows/pre-commit.yml

+41-62
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,77 @@ name: Pre-Commit
22

33
on:
44
pull_request:
5-
push:
65
branches:
6+
- main
77
- master
88

9+
env:
10+
TERRAFORM_DOCS_VERSION: v0.16.0
11+
912
jobs:
10-
# Min Terraform version(s)
11-
getDirectories:
12-
name: Get root directories
13+
collectInputs:
14+
name: Collect workflow inputs
1315
runs-on: ubuntu-latest
16+
outputs:
17+
directories: ${{ steps.dirs.outputs.directories }}
1418
steps:
1519
- name: Checkout
1620
uses: actions/checkout@v2
17-
- name: Install Python
18-
uses: actions/setup-python@v2
19-
- name: Build matrix
20-
id: matrix
21-
run: |
22-
DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))")
23-
echo "::set-output name=directories::$DIRS"
24-
outputs:
25-
directories: ${{ steps.matrix.outputs.directories }}
21+
22+
- name: Get root directories
23+
id: dirs
24+
uses: clowdhaus/terraform-composite-actions/[email protected]
2625

2726
preCommitMinVersions:
28-
name: Min TF validate
29-
needs: getDirectories
27+
name: Min TF pre-commit
28+
needs: collectInputs
3029
runs-on: ubuntu-latest
3130
strategy:
3231
matrix:
33-
directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}
32+
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
3433
steps:
3534
- name: Checkout
3635
uses: actions/checkout@v2
37-
- name: Install Python
38-
uses: actions/setup-python@v2
36+
3937
- name: Terraform min/max versions
4038
id: minMax
41-
uses: clowdhaus/[email protected].2
39+
uses: clowdhaus/[email protected].3
4240
with:
4341
directory: ${{ matrix.directory }}
44-
- name: Install Terraform v${{ steps.minMax.outputs.minVersion }}
45-
uses: hashicorp/setup-terraform@v1
46-
with:
47-
terraform_version: ${{ steps.minMax.outputs.minVersion }}
48-
- name: Install pre-commit dependencies
49-
run: pip install pre-commit
50-
- name: Execute pre-commit
42+
43+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
5144
# Run only validate pre-commit check on min version supported
5245
if: ${{ matrix.directory != '.' }}
53-
run: pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*
54-
- name: Execute pre-commit
46+
uses: clowdhaus/terraform-composite-actions/[email protected]
47+
with:
48+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
49+
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'
50+
51+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
5552
# Run only validate pre-commit check on min version supported
5653
if: ${{ matrix.directory == '.' }}
57-
run: pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)
54+
uses: clowdhaus/terraform-composite-actions/[email protected]
55+
with:
56+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
57+
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'
5858

59-
# Max Terraform version
60-
getBaseVersion:
61-
name: Module max TF version
59+
preCommitMaxVersion:
60+
name: Max TF pre-commit
6261
runs-on: ubuntu-latest
62+
needs: collectInputs
6363
steps:
6464
- name: Checkout
6565
uses: actions/checkout@v2
66+
with:
67+
ref: ${{ github.event.pull_request.head.ref }}
68+
repository: ${{github.event.pull_request.head.repo.full_name}}
69+
6670
- name: Terraform min/max versions
6771
id: minMax
68-
uses: clowdhaus/[email protected]
69-
outputs:
70-
minVersion: ${{ steps.minMax.outputs.minVersion }}
71-
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
72+
uses: clowdhaus/[email protected]
7273

73-
preCommitMaxVersion:
74-
name: Max TF pre-commit
75-
runs-on: ubuntu-latest
76-
needs: getBaseVersion
77-
strategy:
78-
fail-fast: false
79-
matrix:
80-
version:
81-
- ${{ needs.getBaseVersion.outputs.maxVersion }}
82-
steps:
83-
- name: Checkout
84-
uses: actions/checkout@v2
85-
- name: Install Python
86-
uses: actions/setup-python@v2
87-
- name: Install Terraform v${{ matrix.version }}
88-
uses: hashicorp/setup-terraform@v1
74+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
75+
uses: clowdhaus/terraform-composite-actions/[email protected]
8976
with:
90-
terraform_version: ${{ matrix.version }}
91-
- name: Install pre-commit dependencies
92-
run: |
93-
pip install pre-commit
94-
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.13.0/terraform-docs-v0.13.0-$(uname)-amd64.tar.gz && tar -xzf terraform-docs.tar.gz && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
95-
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
96-
- name: Execute pre-commit
97-
# Run all pre-commit checks on max version supported
98-
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}
99-
run: pre-commit run --color=always --show-diff-on-failure --all-files
77+
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
78+
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}

.github/workflows/release.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
paths:
10+
- '**/*.py'
11+
- '**/*.tf'
12+
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
with:
21+
persist-credentials: false
22+
fetch-depth: 0
23+
24+
- name: Release
25+
uses: cycjimmy/semantic-release-action@v2
26+
with:
27+
semantic_version: 18.0.0
28+
extra_plugins: |
29+
@semantic-release/[email protected]
30+
@semantic-release/[email protected]
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}

.pre-commit-config.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
repos:
2-
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.50.0
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.58.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate
77
- id: terraform_docs
8+
args:
9+
- '--args=--lockfile=false'
810
- id: terraform_tflint
911
args:
1012
- '--args=--only=terraform_deprecated_interpolation'
@@ -20,7 +22,7 @@ repos:
2022
- '--args=--only=terraform_required_providers'
2123
- '--args=--only=terraform_standard_module_structure'
2224
- '--args=--only=terraform_workspace_remote'
23-
- repo: git://github.com/pre-commit/pre-commit-hooks
25+
- repo: https://github.com/pre-commit/pre-commit-hooks
2426
rev: v4.0.1
2527
hooks:
2628
- id: check-merge-conflict

.releaserc.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"branches": [
3+
"main",
4+
"master"
5+
],
6+
"ci": false,
7+
"plugins": [
8+
"@semantic-release/commit-analyzer",
9+
"@semantic-release/release-notes-generator",
10+
[
11+
"@semantic-release/github",
12+
{
13+
"successComment":
14+
"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
15+
"labels": false,
16+
"releasedLabels": false
17+
}
18+
],
19+
[
20+
"@semantic-release/changelog",
21+
{
22+
"changelogFile": "CHANGELOG.md",
23+
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
24+
}
25+
],
26+
[
27+
"@semantic-release/git",
28+
{
29+
"assets": [
30+
"CHANGELOG.md"
31+
],
32+
"message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
33+
}
34+
]
35+
]
36+
}

CHANGELOG.md

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# Change Log
2-
3-
All notable changes to this project will be documented in this file.
4-
5-
<a name="unreleased"></a>
6-
## [Unreleased]
7-
8-
9-
101
<a name="v3.4.0"></a>
112
## [v3.4.0] - 2021-09-07
123

Makefile

-7
This file was deleted.

0 commit comments

Comments
 (0)