-
Notifications
You must be signed in to change notification settings - Fork 6
186 lines (151 loc) · 6.11 KB
/
deploy.yaml
File metadata and controls
186 lines (151 loc) · 6.11 KB
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
name: Deployment
on:
workflow_dispatch:
jobs:
build_package_and_deploy:
name: Build, package and deploy
runs-on: ubuntu-latest
timeout-minutes: 90
env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION_DEPLOY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEPLOY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEPLOY }}
AWS_DEFAULT_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 22
cache: "npm"
- name: Install All Dependencies
run: npm run install:all
- name: Compile project
run: npm run build
- name: Generate distribution packages
run: npm run package
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.7.*"
enable-cache: true
- name: Install deployment environment
id: install_deploy_env
run: |
# install deployment environment with eoapi-cdk from build
uv sync --group deploy
uv pip install dist/python/*.gz
cd integration_tests/cdk
npm install
cd -
# use short commit SHA to name stacks
- uses: benjlevesque/short-sha@v3.0
id: short-sha
with:
length: 6
- name: Deploy test stack
id: deploy_step
env:
PROJECT_ID: ${{ steps.short-sha.outputs.sha }}
run: |
# synthesize the stack
cd integration_tests/cdk
uv run npx cdk synth --debug --all --require-approval never
# deploy the stack
uv run npx cdk deploy --ci --all --require-approval never
cd -
- name: Get stack outputs and run operational checks
id: operational_checks
env:
PROJECT_ID: ${{ steps.short-sha.outputs.sha }}
run: |
cd integration_tests/cdk
echo "=== Retrieving Stack Outputs ==="
# Get list of deployed stacks
DEPLOYED_STACKS=$(uv run npx cdk list)
echo "Deployed stacks: $DEPLOYED_STACKS"
# Create outputs file
echo "{}" > stack_outputs.json
# Get outputs from each stack
for STACK_NAME in $DEPLOYED_STACKS; do
echo "Processing stack: $STACK_NAME"
# Try to get outputs using AWS CLI
STACK_OUTPUTS=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" \
--query 'Stacks[0].Outputs' \
--output json 2>/dev/null || echo "[]")
if [ "$STACK_OUTPUTS" != "[]" ] && [ "$STACK_OUTPUTS" != "null" ]; then
echo "Found outputs for $STACK_NAME:"
echo "$STACK_OUTPUTS" | jq .
# Convert to key-value format and merge with existing outputs
TEMP_OUTPUTS=$(echo "$STACK_OUTPUTS" | jq -r 'if . then [.[] | select(.OutputKey and .OutputValue) | {(.OutputKey): .OutputValue}] | add // {} else {} end')
echo "$TEMP_OUTPUTS" > temp_stack_outputs.json
# Merge with existing outputs
jq -s '.[0] * .[1]' stack_outputs.json temp_stack_outputs.json > merged.json
mv merged.json stack_outputs.json
else
echo "No outputs found for $STACK_NAME"
fi
done
echo "=== Final Combined Outputs ==="
cat stack_outputs.json | jq .
echo "=== Running Operational Checks ==="
echo "Available CloudFormation output keys:"
cat stack_outputs.json | jq -r 'keys[]'
STAC_API_URL=$(cat stack_outputs.json | jq -r '
to_entries[] |
select(.key | test("pgstacapistacapioutput"; "i")) |
.value' | head -1)
TITILER_PGSTAC_API_URL=$(cat stack_outputs.json | jq -r '
to_entries[] |
select(.key | test("titilerpgstacapioutput"; "i")) |
.value' | head -1)
TIPG_API_URL=$(cat stack_outputs.json | jq -r '
to_entries[] |
select(.key | test("tipgapioutput"; "i")) |
.value' | head -1)
echo "Extracted URLs:"
echo "STAC_API_URL: $STAC_API_URL"
echo "TITILER_PGSTAC_API_URL: $TITILER_PGSTAC_API_URL"
echo "TIPG_API_URL: $TIPG_API_URL"
# Array of API URLs to check
declare -a API_HEALTH_ENDPOINTS=(
"STAC_API_URL:${STAC_API_URL}_mgmt/health"
"TITILER_PGSTAC_API_URL:${TITILER_PGSTAC_API_URL}healthz"
"TIPG_API_URL:${TIPG_API_URL}healthz"
)
# Check each API
echo "=== Sleeping for 5 minutes to ensure everything is running ==="
sleep 300
for API_INFO in "${API_HEALTH_ENDPOINTS[@]}"; do
API_NAME=$(echo "$API_INFO" | cut -d: -f1)
API_URL=$(echo "$API_INFO" | cut -d: -f2-)
if [ -n "$API_URL" ] && [ "$API_URL" != "null" ]; then
echo "Checking $API_NAME at: $API_URL"
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 "$API_URL" || echo "000")
if [ "$HTTP_STATUS" = "200" ]; then
echo "✅ $API_NAME returned 200"
else
echo "❌ $API_NAME returned $HTTP_STATUS"
exit 1
fi
else
echo "⚠️ $API_NAME URL not found in stack outputs"
fi
done
echo "=== Operational Checks Complete ==="
cd -
- name: Tear down any infrastructure
if: always()
env:
PROJECT_ID: ${{ steps.short-sha.outputs.sha }}
run: |
cd integration_tests/cdk
# run this only if we find a 'cdk.out' directory, which means there might be things to tear down
if [ -d "cdk.out" ]; then
cd -
cd integration_tests/cdk
# see https://github.com/aws/aws-cdk/issues/24946
# this didn't work : rm -f cdk.out/synth.lock
# so we just duplicate the cdk output to cdk-destroy.out
uv run npx cdk destroy --output cdk-destroy.out --ci --all --force
fi