-
Notifications
You must be signed in to change notification settings - Fork 67
98 lines (88 loc) · 4.5 KB
/
aws-prod.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
on:
push:
branches:
- main
name: Deploy to AWS Production
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
AWS_REGION: us-east-1
ECR_REPO_NAME: summer-fi-prod
SERVICE_NAME: summer-fi-prod
CLUSTER_NAME: summer-fi-prod
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Extract commit hash
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
SHA_TAG: ${{ steps.vars.outputs.sha_short }}
LATEST_TAG: latest
ENVIRONMENT_TAG: prod
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -f Dockerfile.production \
--build-arg COMMIT_SHA='' \
--build-arg AJNA_SUBGRAPH_URL=${{ secrets.AJNA_SUBGRAPH_URL_PROD }} \
--build-arg AJNA_SUBGRAPH_URL_GOERLI=${{ secrets.AJNA_SUBGRAPH_URL_GOERLI }} \
--build-arg AJNA_SUBGRAPH_V2_URL=${{ secrets.AJNA_SUBGRAPH_V2_URL_PROD }} \
--build-arg AJNA_SUBGRAPH_V2_URL_GOERLI=${{ secrets.AJNA_SUBGRAPH_V2_URL_GOERLI }} \
--build-arg MIXPANEL_ENV=production \
--build-arg MIXPANEL_KEY=${{ secrets.MIXPANEL_KEY_PROD }} \
--build-arg INFURA_PROJECT_ID=${{ secrets.INFURA_PROJECT_ID_PROD }} \
--build-arg ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }} \
--build-arg BLOCKNATIVE_API_KEY=${{ secrets.BLOCKNATIVE_API_KEY_PROD }} \
--build-arg SHOW_BUILD_INFO=0 \
--build-arg NODE_ENV=production \
--build-arg NEXT_PUBLIC_SENTRY_ENV=production \
--build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
--build-arg PRODUCT_HUB_KEY=${{ secrets.PRODUCT_HUB_KEY }} \
--build-arg ONE_INCH_API_KEY=${{ secrets.ONE_INCH_API_KEY_PROD }} \
--build-arg ONE_INCH_API_URL=${{ secrets.ONE_INCH_API_URL_PROD }} \
--build-arg REFERRAL_SUBGRAPH_URL=${{ secrets.REFERRAL_SUBGRAPH_URL_PROD }} \
--build-arg CONFIG_URL=${{ secrets.CONFIG_URL }} \
--build-arg NPM_TOKEN=${{ secrets.NPM_TOKEN }} \
--build-arg BLOG_POSTS_API_KEY=${{ secrets.BLOG_POSTS_API_KEY }} \
--build-arg BLOG_POSTS_API_URL=${{ secrets.BLOG_POSTS_API_URL }} \
--build-arg NEXT_PUBLIC_SPINDL_SDK_KEY=${{ secrets.NEXT_PUBLIC_SPINDL_SDK_KEY }} \
--build-arg NEWSLETTER_API_KEY=${{ secrets.NEWSLETTER_API_KEY }} \
--build-arg NEWSLETTER_PUBLICATION_ID=${{ secrets.NEWSLETTER_PUBLICATION_ID }} \
--build-arg NEWSLETTER_ENDPOINT=${{ secrets.NEWSLETTER_ENDPOINT }} \
--cache-from=$ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \
-t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \
-t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \
-t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \
.
docker push $ECR_REGISTRY/$ECR_REPO_NAME --all-tags
- name: Update ECS service with latest Docker image
id: service-update
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
- name: Wait for all services to become stable
uses: oryanmoshe/[email protected]
with:
ecs-cluster: ${{ env.CLUSTER_NAME }}
ecs-services: '["${{ env.SERVICE_NAME }}"]'
- name: Invalidate CloudFront
run:
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{
secrets.CF_DIST_ID_PROD }} --paths "/*"