Repository navigation
68 lines (56 loc) · 1.88 KB
/
Copy pathdeploy.yml
File metadata and controls
68 lines (56 loc) · 1.88 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
name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: "Target environment"
required: true
type: choice
options:
- mainnet
tag:
description: "Image tag (commit SHA or latest)"
required: false
default: "latest"
permissions:
id-token: write
contents: read
env:
AWS_REGION: us-east-1
jobs:
deploy-indexer:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- uses: aws-actions/amazon-ecr-login@v2
id: ecr
- name: Deploy indexer to ${{ inputs.environment }}
env:
REGISTRY: ${{ steps.ecr.outputs.registry }}
CLUSTER: lava-indexer-${{ inputs.environment }}
TAG: ${{ inputs.tag }}
run: |
IMAGE="${REGISTRY}/lava-indexer:${TAG}"
echo "Deploying ${IMAGE} to ${CLUSTER}/indexer"
TASK_DEF=$(aws ecs describe-task-definition \
--task-definition ${CLUSTER}-indexer \
--query 'taskDefinition' \
--output json)
UPDATED=$(echo "$TASK_DEF" | jq \
--arg IMG "$IMAGE" \
'.containerDefinitions[0].image = $IMG |
{family, taskRoleArn, executionRoleArn, networkMode,
containerDefinitions, requiresCompatibilities, cpu, memory}')
NEW_ARN=$(aws ecs register-task-definition \
--cli-input-json "$UPDATED" \
--query 'taskDefinition.taskDefinitionArn' \
--output text)
aws ecs update-service \
--cluster "$CLUSTER" \
--service indexer \
--task-definition "$NEW_ARN"
echo "Deployed ${IMAGE} → ${CLUSTER}/indexer (task def: ${NEW_ARN})"