-
-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (101 loc) · 3.35 KB
/
terragrunt.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: 'Terragrunt'
on:
pull_request:
branches: [ "main" ]
paths:
- "tf/deployment/**"
- ".github/workflows/terragrunt.yaml"
push:
branches: [ "main" ]
paths:
- "tf/deployment/**"
- ".github/workflows/terragrunt.yaml"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
env:
tofu_version: '1.7.1'
tg_version: '0.58.12'
working_dir: 'tf/deployment'
TERRAGRUNT_PARALLELISM: 1
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@main
- name: Install 1Password CLI
uses: 1password/install-cli-action@v1
- name: Install Terragrunt
uses: eLco/setup-terragrunt@v1
with:
terragrunt_version: ${{ env.tg_version }}
- name: 'Install OpenTofu'
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.tofu_version }}
tofu_wrapper: false
- name: Check Formatting
uses: gruntwork-io/terragrunt-action@v2
with:
tofu_version: ${{ env.tofu_version }}
tg_version: ${{ env.tg_version }}
tg_dir: ${{ env.working_dir }}
tg_command: 'hclfmt --terragrunt-check --terragrunt-diff'
- name: Check terraform fmt
working-directory: ${{ env.working_dir }}
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_TF_PROD_ENV }}
run: op run --env-file=".env" -- terragrunt run-all fmt -diff -check
plan:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- name: 'Checkout'
uses: actions/checkout@main
- name: Install 1Password CLI
uses: 1password/install-cli-action@v1
- name: Install Terragrunt
uses: eLco/setup-terragrunt@v1
with:
terragrunt_version: ${{ env.tg_version }}
- name: 'Install OpenTofu'
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.tofu_version }}
tofu_wrapper: false
- name: Plan All
working-directory: ${{ env.working_dir }}
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_TF_PROD_ENV }}
run: op run --env-file=".env" -- terragrunt run-all plan -no-color 2>&1 | tee "${{github.workspace}}/plan_output.txt" && exit ${PIPESTATUS[0]};
# - name: 'List files'
# run: 'ls -la ${{ github.workspace }}'
# - name: Comment Terraform Plan on PR
# uses: blinqas/tf-plan-pr-comment@v1
# with:
# output_file: "${{ github.workspace }}/plan_output.txt"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: 'Checkout'
uses: actions/checkout@main
- name: Install 1Password CLI
uses: 1password/install-cli-action@v1
- name: Install Terragrunt
uses: eLco/setup-terragrunt@v1
with:
terragrunt_version: ${{ env.tg_version }}
- name: 'Install OpenTofu'
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.tofu_version }}
tofu_wrapper: false
- name: Deploy All
working-directory: ${{ env.working_dir }}
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_TF_PROD_ENV }}
run: op run --env-file=".env" -- terragrunt run-all apply --terragrunt-non-interactive