-
Notifications
You must be signed in to change notification settings - Fork 3
97 lines (83 loc) · 3.07 KB
/
deploy-prod.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
name: Deploy Prod
on:
push:
branches:
- prod
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment:
name: prod
url: ${{ vars.URL }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 4
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "yarn"
- name: install
run: yarn install
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ECS_DEPLOY_ACCESS_KEY_SELECT }}
aws-secret-access-key: ${{ secrets.AWS_ECS_DEPLOY_SECRET_KEY_SELECT }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@aaf69d68aa3fb14c1d5a6be9ac61fe15b48453a2
env:
AWS_REGION: ${{ vars.AWS_REGION }}
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
DOCKER_BUILDKIT: 1
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG} .
docker push ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG}
- name: Install kubectl
uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4.0.0
with:
version: latest
- name: Set up EKS kubeconfig
run: aws eks update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME }}
env:
AWS_REGION: ${{ vars.AWS_REGION }}
- name: Update Deployment in Kubernetes
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
kubectl --namespace ${{ vars.NAMESPACE }} set image deployment/deployment app=$ECR_REGISTRY/${ECR_REPOSITORY}:${IMAGE_TAG}
kubectl rollout status deployment
- name: invalidate cloudfront distribution and wait for completion
run: |
PATHS=('/' '/*')
INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --query 'Invalidation.Id' --output text --paths "${PATHS[@]}")
aws cloudfront wait invalidation-completed --distribution-id $DISTRIBUTION_ID --id $INVALIDATION_ID
env:
DISTRIBUTION_ID: ${{ secrets.DISTRIBUTION_ID }}
# - name: Notify deploy to Rollbar
# uses: rollbar/[email protected]
# id: rollbar_deploy
# with:
# environment: "prod"
# version: ${{ github.sha }}
# env:
# ROLLBAR_ACCESS_TOKEN: ${{ secrets.ROLLBAR_ACCESS_TOKEN }}
# ROLLBAR_USERNAME: ${{ github.actor }}