Skip to content

Commit 6385968

Browse files
committed
Sync from management repo
1 parent e5b0dbd commit 6385968

File tree

4 files changed

+99
-47
lines changed

4 files changed

+99
-47
lines changed

.github/workflows/pre-commit.yml

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- main
87
- develop
8+
- main
99

1010
jobs:
11-
# Min Terraform version(s)
1211
getDirectories:
1312
name: Get root directories
1413
runs-on: ubuntu-latest
@@ -31,7 +30,7 @@ jobs:
3130
directories: ${{ steps.matrix.outputs.directories }}
3231

3332
preCommitMinVersions:
34-
name: Min TF validate
33+
name: Min validate
3534
needs: getDirectories
3635
runs-on: ubuntu-latest
3736
strategy:
@@ -58,11 +57,9 @@ jobs:
5857
with:
5958
terraform_version: ${{ steps.minMax.outputs.minVersion }}
6059

61-
- name: Install pre-commit dependencies
60+
- name: Install pre-commit
6261
run: pip install pre-commit
6362

64-
65-
# Max Terraform version
6663
getBaseVersion:
6764
name: Module max TF version
6865
runs-on: ubuntu-latest
@@ -78,7 +75,7 @@ jobs:
7875
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
7976

8077
preCommitMaxVersion:
81-
name: Max TF pre-commit
78+
name: Max pre-commit
8279
runs-on: ubuntu-latest
8380
needs: getBaseVersion
8481
strategy:
@@ -105,10 +102,59 @@ jobs:
105102
run: |
106103
pip install pre-commit
107104
pip install checkov
108-
curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-v1.0.1-linux-amd64" | head -n1)" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
109105
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/
110106
111107
- name: Execute pre-commit
112-
# Run all pre-commit checks on max version supported
113-
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}
114-
run: pre-commit run --color=always --show-diff-on-failure --all-files
108+
continue-on-error: true # To avoid pre-commit failure
109+
run: |
110+
pre-commit run --color=always --show-diff-on-failure --all-files
111+
112+
- name: Get current branch name
113+
id: vars
114+
run: |
115+
echo ::set-output name=branch_name::${GITHUB_REF##*/}
116+
117+
- name: "Get branch name and save to env"
118+
env:
119+
IS_PR: ${{ github.EVENT_NAME == 'pull_request' }}
120+
run: |
121+
if ${IS_PR}; then
122+
BRANCH_NAME="${GITHUB_HEAD_REF}"
123+
else
124+
BRANCH_NAME="${GITHUB_REF##*/}"
125+
fi
126+
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
127+
128+
- uses: actions/checkout@v2
129+
with:
130+
ref: ${{ github.event.pull_request.head.ref }}
131+
132+
- name: Render terraform docs and commit changes
133+
if: ${{ env.BRANCH_NAME }} == 'develop'
134+
uses: terraform-docs/gh-actions@main
135+
with:
136+
working-dir: .
137+
output-file: README.md
138+
output-method: inject
139+
git-push: "true"
140+
141+
- name: Commit pre-commit modified files
142+
if: ${{ env.BRANCH_NAME }} == 'develop'
143+
run: |
144+
git config --local user.email "terraform+github-actions[bot]@users.noreply.github.com"
145+
git config --local user.name "github-actions[bot]"
146+
git diff-index --quiet HEAD || (git add -A && git commit -m'[bot] update files' --allow-empty && git push -f)
147+
148+
- uses: actions/checkout@v2
149+
- name: Create PR
150+
continue-on-error: true
151+
uses: repo-sync/pull-request@v2
152+
if: ${{ env.BRANCH_NAME }} == 'develop'
153+
with:
154+
source_branch: "develop"
155+
destination_branch: "main"
156+
pr_title: "Pulling ${{ github.ref }} into main"
157+
pr_body: ":crown: *Automated PR*"
158+
pr_label: "auto-pr"
159+
pr_allow_empty: false
160+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/state-actions.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Mark or close stale issues and PRs"
2+
on:
3+
schedule:
4+
- cron: "0 0 10 * *"
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v4
11+
with:
12+
repo-token: ${{ secrets.GITHUB_TOKEN }}
13+
# Staling issues and PR's
14+
days-before-stale: 30
15+
stale-issue-label: stale
16+
stale-pr-label: stale
17+
stale-issue-message: |
18+
This issue has been automatically marked as stale because it has been open 30 days
19+
with no activity. Remove stale label or comment or this issue will be closed in 10 days
20+
stale-pr-message: |
21+
This PR has been automatically marked as stale because it has been open 30 days
22+
with no activity. Remove stale label or comment or this PR will be closed in 10 days
23+
# Not stale if have this labels or part of milestone
24+
exempt-issue-labels: bug,wip,on-hold
25+
exempt-pr-labels: bug,wip,on-hold
26+
exempt-all-milestones: true
27+
# Close issue operations
28+
# Label will be automatically removed if the issues are no longer closed nor locked.
29+
days-before-close: 10
30+
delete-branch: false
31+
close-issue-message: This issue was automatically closed because of stale in 10 days
32+
close-pr-message: This PR was automatically closed because of stale in 10 days

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.60.0
3+
rev: v1.64.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_tflint
@@ -12,7 +12,7 @@ repos:
1212
- '--args=--only=terraform_documented_outputs'
1313
- '--args=--only=terraform_documented_variables'
1414
- '--args=--only=terraform_typed_variables'
15-
- '--args=--only=terraform_module_pinned_source'
15+
#- '--args=--only=terraform_module_pinned_source'
1616
- '--args=--only=terraform_naming_convention'
1717
- '--args=--only=terraform_required_providers'
1818
- '--args=--only=terraform_standard_module_structure'

README.md

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -108,54 +108,28 @@ module "target_group" {
108108

109109
Please refer to examples directory [link](examples) for references.
110110

111+
<!-- BEGIN_TF_DOCS -->
111112
## Requirements
112113

113-
| Name | Version |
114-
|------|---------|
115-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.1 |
116-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 3.63 |
114+
No requirements.
117115

118116
## Providers
119117

120-
| Name | Version |
121-
|------|---------|
122-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.63 |
118+
No providers.
123119

124120
## Modules
125121

126-
| Name | Source | Version |
127-
|------|--------|---------|
128-
| <a name="module_global"></a> [global](#module\_global) | git::git@github.com:tomarv2/terraform-global.git//aws | v0.0.1 |
122+
No modules.
129123

130124
## Resources
131125

132-
| Name | Type |
133-
|------|------|
134-
| [aws_lb_target_group.target_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group) | resource |
135-
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
136-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
126+
No resources.
137127

138128
## Inputs
139129

140-
| Name | Description | Type | Default | Required |
141-
|------|-------------|------|---------|:--------:|
142-
| <a name="input_deploy_target_group"></a> [deploy\_target\_group](#input\_deploy\_target\_group) | Feature flag, true or false | `bool` | `true` | no |
143-
| <a name="input_deregistration_delay"></a> [deregistration\_delay](#input\_deregistration\_delay) | deregistration delay | `string` | `"300"` | no |
144-
| <a name="input_healthcheck_interval"></a> [healthcheck\_interval](#input\_healthcheck\_interval) | health check interval | `string` | `""` | no |
145-
| <a name="input_healthcheck_matcher"></a> [healthcheck\_matcher](#input\_healthcheck\_matcher) | healthcheck matcher (e.g. 200) | `string` | `""` | no |
146-
| <a name="input_healthcheck_path"></a> [healthcheck\_path](#input\_healthcheck\_path) | target group health check path | `string` | `""` | no |
147-
| <a name="input_healthcheck_timeout"></a> [healthcheck\_timeout](#input\_healthcheck\_timeout) | health check timeout | `string` | `""` | no |
148-
| <a name="input_healthy_threshold"></a> [healthy\_threshold](#input\_healthy\_threshold) | target group health check threshold | `string` | `""` | no |
149-
| <a name="input_lb_port"></a> [lb\_port](#input\_lb\_port) | load balancer port | `list(any)` | <pre>[<br> 80<br>]</pre> | no |
150-
| <a name="input_lb_protocol"></a> [lb\_protocol](#input\_lb\_protocol) | load balancer protocol | `string` | `"HTTP"` | no |
151-
| <a name="input_prjid"></a> [prjid](#input\_prjid) | Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply' | `string` | n/a | yes |
152-
| <a name="input_stickiness"></a> [stickiness](#input\_stickiness) | Target group sticky configuration | <pre>object({<br> cookie_duration = number<br> enabled = bool<br> })</pre> | `null` | no |
153-
| <a name="input_target_type"></a> [target\_type](#input\_target\_type) | target type | `string` | `"instance"` | no |
154-
| <a name="input_teamid"></a> [teamid](#input\_teamid) | Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply' | `string` | n/a | yes |
155-
| <a name="input_unhealthy_threshold"></a> [unhealthy\_threshold](#input\_unhealthy\_threshold) | target group unhealthy health check threshold | `string` | `""` | no |
130+
No inputs.
156131

157132
## Outputs
158133

159-
| Name | Description |
160-
|------|-------------|
161-
| <a name="output_target_group_arn"></a> [target\_group\_arn](#output\_target\_group\_arn) | Target group arn |
134+
No outputs.
135+
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)