-
Notifications
You must be signed in to change notification settings - Fork 3
93 lines (79 loc) · 3.03 KB
/
deploy.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
name: Deploy To AWS
on:
push:
branches:
- '1.x'
- 'development'
workflow_dispatch:
jobs:
Build:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install --update
- name: AWS ECR
uses: kciter/aws-ecr-action@v5
with:
access_key_id: ${{ secrets.AWS_ACCESS_KEY_CICD }}
secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CICD }}
account_id: 617498580299
repo: ${{ secrets.INSTANCE_NAME }}
region: ${{ secrets.AWS_REGION }}
create_repo: true
tags: latest,${{ github.run_number }},
dockerfile: ${{ github.ref_name }}.Dockerfile
Deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
needs: Build
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: set-vars
run: |
cat .github/workflows/${GITHUB_REF##*/}-destinations >> $GITHUB_ENV
- name: Install Kubernetes toolset
uses: stefanprodan/[email protected]
with:
kubectl: 1.23.0
- name: Download Configmap
uses: keithweaver/[email protected]
with:
command: cp
source: ${{ secrets.CONFIGMAP }}
destination: helm/templates/envconfigmap.yaml
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_CICD }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CICD }}
aws_region: ${{ secrets.AWS_REGION }}
- name: Deploy helm chart
run: |
#configure aws login
if rm -rf /home/runner/.aws
then
echo old credentials removed
fi
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_CICD }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_CICD }}
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.CLUSTER_NAME }}
# For now ignore managed-cert file to avoid conflict with gcp
touch helm/.helmignore
echo "managed-cert.yaml" >> helm/.helmignore
echo "svc-gcp-lb.yaml" >> helm/.helmignore
echo "ingress-gcp-lb.yaml" >> helm/.helmignore
#deploy or upgrade helm chart
helm upgrade --install ${{ secrets.INSTANCE_NAME }} helm \
--namespace ${{ secrets.INSTANCE_NAME }} \
--create-namespace \
--set apiImage=${{ secrets.API_IMAGE }}:${{ github.run_number }} \
--set services.loadBalancer.name=${{ secrets.SERVICE_LOADBALANCER }} \
--set services.loadBalancer.lbSSLCert=${{ secrets.LB_SSLCERT }}