-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 2.88 KB
/
workflow.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
99
100
101
102
103
104
105
106
107
108
109
name: Deploy to EKS
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Terraform Linting
run: |
cd ecr_repository
terraform fmt -check
terraform validate
cd ../eks_cluster
terraform fmt -check
terraform validate
env:
TF_VAR_aws_region: us-east-1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Set up kubectl
uses: azure/setup-kubectl@v1
with:
install-missing: true
- name: Terraform Setup for ECR
run: |
cd ecr_repository
terraform init
env:
TF_VAR_aws_region: us-east-1
- name: Terraform Apply for ECR
run: |
cd ecr_repository
terraform apply -auto-approve
env:
TF_VAR_aws_region: us-east-1
- name: Docker Build and Push
run: |
cd app
docker build -t my-app .
docker tag my-app:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
- name: Terraform Setup for EKS Cluster
run: |
cd eks_cluster
terraform init
env:
TF_VAR_aws_region: us-east-1
- name: Terraform Apply for EKS Cluster
run: |
cd eks_cluster
terraform apply -auto-approve
env:
TF_VAR_aws_region: us-east-1
- name: Terraform Setup for Helm Deployment
run: |
cd helm
terraform init
env:
TF_VAR_aws_region: us-east-1
- name: Terraform Apply for Helm Deployment
run: |
cd helm
terraform apply -auto-approve
env:
TF_VAR_aws_region: us-east-1
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Add Prometheus and Grafana Helm Repositories
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
- name: Deploy Prometheus
run: |
helm install prometheus prometheus-community/prometheus -f helm/prometheus-values.yaml
- name: Deploy Grafana
run: |
helm install grafana grafana/grafana -f helm/grafana-values.yaml
- name: Test Step (Add Your Test Command)
run: |
# Add your test command here
echo "Running tests..."