-
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (163 loc) · 5.26 KB
/
tiles-worker.yml
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Tiles Worker
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
tofu_version: '1.7.1'
tg_version: '0.58.12'
jobs:
test:
name: Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tiles
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: './tiles/.nvmrc'
- name: Run npm install
run: npm ci
- name: Run linter
run: npm run lint
if: ${{ !cancelled() }}
- name: Run formatter
run: npm run format
if: ${{ !cancelled() }}
- name: Run tsc
run: npm run check
if: ${{ !cancelled() }}
- name: Run unit tests & coverage
run: npm run test:cov
if: ${{ !cancelled() }}
build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tiles
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: './tiles/.nvmrc'
- name: Run npm install
run: npm ci
- name: Run tsc
run: npm run check
if: ${{ !cancelled() }}
- name: Wrangler build
run: npm run build
if: ${{ !cancelled() }}
- name: Upload build output
uses: actions/upload-artifact@v4
with:
name: tiles-build-output
path: tiles/dist
retention-days: 14
if: ${{ !cancelled() }}
check-terragrunt:
name: Check Terragrunt
runs-on: ubuntu-latest
defaults:
run:
working-directory: deployment
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
run: terragrunt hclfmt --terragrunt-check --terragrunt-diff
- name: Check TF fmt
env:
ENVIRONMENT: dev
OP_SERVICE_ACCOUNT_TOKEN: ${{ matrix.environment == 'prod' && secrets.OP_TF_PROD_ENV || secrets.OP_TF_DEV_ENV }}
TF_VAR_tiles_build_dir: "${{ github.workspace }}/dist"
run: op run --env-file=".env" -- terragrunt run-all fmt -diff -check
plan-terragrunt:
needs: build
name: Plan Terragrunt
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
environment: [dev, prod]
if: github.ref != 'refs/heads/main' && github.event_name != 'workflow_dispatch'
steps:
- name: 'Checkout'
uses: actions/checkout@main
- name: Install Terragrunt
uses: eLco/setup-terragrunt@v1
with:
terragrunt_version: ${{ env.tg_version }}
- name: Install 1Password CLI
uses: 1password/install-cli-action@v1
- name: 'Install OpenTofu'
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.tofu_version }}
tofu_wrapper: false
- name: 'Get build artifact'
uses: actions/download-artifact@v4
with:
name: tiles-build-output
path: "${{ github.workspace }}/dist"
- name: Plan All
working-directory: ${{ github.workspace }}/deployment
env:
ENVIRONMENT: ${{ matrix.environment }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ matrix.environment == 'prod' && secrets.OP_TF_PROD_ENV || secrets.OP_TF_DEV_ENV }}
TF_VAR_tiles_build_dir: "${{ github.workspace }}/dist"
run: op run --env-file=".env" -- terragrunt run-all plan -no-color 2>&1 | tee "${{github.workspace}}/plan_output.txt" && exit ${PIPESTATUS[0]};
deploy-terragrunt:
needs: [build, test]
name: Deploy Terragrunt
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
env:
ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}
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: 'Get build artifact'
uses: actions/download-artifact@v4
with:
name: tiles-build-output
path: "${{ github.workspace }}/dist"
- name: Deploy All
working-directory: ${{ github.workspace }}/deployment
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.OP_TF_PROD_ENV || secrets.OP_TF_DEV_ENV }}
TF_VAR_tiles_build_dir: "${{ github.workspace }}/dist"
run: op run --env-file=".env" -- terragrunt run-all apply --terragrunt-non-interactive