forked from kodekloudhub/learning-app-ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (90 loc) · 2.86 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: PHP App CI/CD
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: PHP testing
run: echo "php test"
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: false
tags: ecom-web:v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: |
docker tag ecom-web:v2 ${{ secrets.DOCKERHUB_USERNAME }}/ecom-web:v2
docker push ${{ secrets.DOCKERHUB_USERNAME }}/ecom-web:v2
terraform:
name: "terraform"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
working-directory: ./terraform
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform init
run: terraform init
- name: Terraform Validate
run: terraform validate -no-color
- name: Terraform Plan
run: terraform plan -no-color
- name: Terraform Apply
run: terraform apply --auto-approve -no-color
- name: Terraform Destroy
run: terraform destroy --auto-approve -no-color
kubernetes:
needs: terraform
name: "deploy to eks"
runs-on: ubuntu-latest
env:
EKS_CLUSTER_NAME: ecommerce-app-cluster
AWS_REGION: eu-north-1
defaults:
run:
working-directory: ./kubernetes
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
working-directory: ./kubernetes
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{env.AWS_REGION}}
- name: Update kube config
run: aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $AWS_REGION
- name: Create secret to pull image
run: kubectl create secret docker-registry regcred --docker-server=docker.io --docker-username=${{ secrets.DOCKERHUB_USERNAME }} --docker-password=${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy To EKS
run: |
kubectl apply -f mariadb-secret.yml
kubectl apply -f mariadb-configmap.yml
kubectl apply -f mariadb.yml
kubectl apply -f mariadb-svc.yml
kubectl apply -f ecom-web-configmap.yml
kubectl apply -f feature-toggle.yml
kubectl apply -f ecom-web.yml
kubectl apply -f ecom-web-svc.yml