Skip to content

Commit fe48908

Browse files
authored
chore: sync with latest template state (#15)
This PR syncs the repository with the latest state from . **Changes include:** - Updated configuration files (.checkov.yaml, .markdownlint.yaml, etc.) - Updated GitHub workflows and templates - Updated linting and formatting configurations - Updated documentation templates
1 parent 3d84fe2 commit fe48908

File tree

9 files changed

+133
-5
lines changed

9 files changed

+133
-5
lines changed
File renamed without changes.

.github/workflows/lint.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ concurrency:
44
group: lint-${{ github.head_ref || github.run_id }}
55
cancel-in-progress: true
66

7-
on: pull_request
7+
on: pull_request_target
88

99
permissions:
1010
actions: read
@@ -20,6 +20,10 @@ jobs:
2020
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121
- name: Trunk Check
2222
uses: trunk-io/trunk-action@4d5ecc89b2691705fd08c747c78652d2fc806a94 # v1.1.19
23+
env:
24+
# NOTE: inject the GITHUB_TOKEN for the trunk managed tflint linter
25+
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2327

2428
conventional-title:
2529
runs-on: ubuntu-latest

.github/workflows/release-please.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ jobs:
1414
release-please:
1515
runs-on: ubuntu-latest
1616
steps:
17+
- name: Create Token for MasterpointBot App
18+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a #v2.1.0
19+
id: generate-token
20+
with:
21+
app_id: ${{ secrets.MP_BOT_APP_ID }}
22+
private_key: ${{ secrets.MP_BOT_APP_PRIVATE_KEY }}
23+
1724
- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f #v4.1.3
1825
with:
26+
token: ${{ steps.generate-token.outputs.token }}
1927
release-type: terraform-module

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
7+
pull_request_target:
88

99
permissions:
1010
actions: read

.github/workflows/trunk-upgrade.yaml

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,78 @@ jobs:
3434
reviewers: "@masterpointio/masterpoint-internal"
3535
prefix: "chore: "
3636

37-
- name: Merge PR automatically
37+
- name: Wait for checks to pass + Merge PR
3838
if: steps.trunk-upgrade.outputs.pull-request-number != ''
3939
env:
40-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
40+
GH_TOKEN: ${{ secrets.MASTERPOINT_TEAM_PAT }}
4141
PR_NUMBER: ${{ steps.trunk-upgrade.outputs.pull-request-number }}
4242
run: |
43-
gh pr merge "$PR_NUMBER" --squash --auto --delete-branch
43+
echo "Waiting for status checks to pass on PR #$PR_NUMBER..."
44+
45+
# Wait a bit for checks to start
46+
echo "Waiting 30 seconds for checks to initialize..."
47+
sleep 30
48+
49+
# Try to get all checks first to see if any exist
50+
ALL_CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --json state,bucket || echo "[]")
51+
echo "All checks: $ALL_CHECKS_JSON"
52+
53+
# Get required checks
54+
REQUIRED_CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket || echo "[]")
55+
echo "Required checks: $REQUIRED_CHECKS_JSON"
56+
57+
# Check if we have any required checks
58+
REQUIRED_CHECKS_COUNT=$(echo "$REQUIRED_CHECKS_JSON" | jq '. | length')
59+
ALL_CHECKS_COUNT=$(echo "$ALL_CHECKS_JSON" | jq '. | length')
60+
61+
if [ "$REQUIRED_CHECKS_COUNT" -eq 0 ] && [ "$ALL_CHECKS_COUNT" -eq 0 ]; then
62+
echo "No status checks found. This might be expected if no checks are configured."
63+
echo "Proceeding with auto-approval and merge..."
64+
65+
# Auto-approve the PR
66+
gh pr review "$PR_NUMBER" --approve --body "Auto-approved by trunk upgrade workflow (no status checks configured)"
67+
68+
# Merge the PR
69+
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
70+
exit 0
71+
fi
72+
73+
# If we have required checks, wait for them. Otherwise, wait for all checks.
74+
if [ "$REQUIRED_CHECKS_COUNT" -gt 0 ]; then
75+
echo "Waiting for $REQUIRED_CHECKS_COUNT required status checks..."
76+
CHECKS_TO_MONITOR="required"
77+
else
78+
echo "No required checks configured. Waiting for all $ALL_CHECKS_COUNT status checks..."
79+
CHECKS_TO_MONITOR="all"
80+
fi
81+
82+
# Wait for checks to complete
83+
while true; do
84+
if [ "$CHECKS_TO_MONITOR" = "required" ]; then
85+
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket)
86+
else
87+
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --json state,bucket)
88+
fi
89+
90+
echo "Current checks status: $CHECKS_JSON"
91+
92+
if echo "$CHECKS_JSON" | jq -e '.[] | select(.bucket=="fail")' > /dev/null; then
93+
echo "One or more checks have failed. Exiting..."
94+
exit 1
95+
fi
96+
97+
FAILED_OR_PENDING_CHECKS=$(echo "$CHECKS_JSON" | jq '[.[] | select(.state!="SUCCESS" or .bucket!="pass")] | length')
98+
if [ "$FAILED_OR_PENDING_CHECKS" -eq 0 ]; then
99+
echo "All checks passed. Auto-approving and merging PR https://github.com/${{ github.repository }}/pull/$PR_NUMBER..."
100+
101+
# Auto-approve the PR
102+
gh pr review "$PR_NUMBER" --approve --body "Auto-approved by trunk upgrade workflow"
103+
104+
# Merge the PR
105+
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
106+
break
107+
else
108+
echo "Some checks are still running or pending. Retrying in 30s..."
109+
sleep 30
110+
fi
111+
done

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# IDE/Editor settings
1717
**/.idea
1818
**/*.iml
19+
.cursor/
1920
.vscode/
2021
*.orig
2122
*.draft
@@ -44,3 +45,8 @@ backend.tf.json
4445
**/*.bak
4546
**/*.*swp
4647
**/.DS_Store
48+
49+
# AI code gen tools - we beleive engineers are responsible for the code they push no matter how it's generated
50+
.claude/*
51+
.cursor/*
52+
CLAUDE.md
File renamed without changes.

.tflint.hcl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
plugin "terraform" {
2+
enabled = true
3+
preset = "all"
4+
}
5+
6+
config {
7+
format = "compact"
8+
9+
# Inspect vars passed into "module" blocks. eg, lint AMI value passed into ec2 module.
10+
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md
11+
call_module_type = "all"
12+
13+
# default values but keeping them here for clarity
14+
disabled_by_default = false
15+
force = false
16+
}
17+
18+
# Installing tflint rulesets from Github requires setting a GITHUB_TOKEN
19+
# environment variable. Without it, you'll get an error like this:
20+
# $ tflint --init
21+
# Installing "aws" plugin...
22+
# Failed to install a plugin; Failed to fetch GitHub releases: GET https://api.github.com/repos/terraform-linters/tflint-ruleset-aws/releases/tags/v0.39.0: 401 Bad credentials []
23+
#
24+
# The solution is to provide a github PAT via a GITHUB_TOKEN env var,
25+
# export GITHUB_TOKEN=github_pat_120abc123def456ghi789jkl123mno456pqr789stu123vwx456yz789
26+
#
27+
# See docs for more info: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
28+
plugin "aws" {
29+
enabled = true
30+
version = "0.39.0"
31+
source = "github.com/terraform-linters/tflint-ruleset-aws"
32+
deep_check = false
33+
}
34+
35+
# Allow variables to exist in more files than ONLY variables.tf
36+
# Example use cases where we prefer for variables to exist in context,
37+
# - context.tf (applicable to the null-label module)
38+
# - providers.tf (when passing in secret keys from SOPs - example, github provider)
39+
# https://github.com/terraform-linters/tflint-ruleset-terraform/blob/main/docs/rules/terraform_standard_module_structure.md
40+
rule "terraform_standard_module_structure" {
41+
enabled = false
42+
}
File renamed without changes.

0 commit comments

Comments
 (0)