-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (98 loc) · 3.56 KB
/
deploy.yml
File metadata and controls
110 lines (98 loc) · 3.56 KB
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
name: deploy
# See https://github.com/marketplace/actions/deploy-to-kubernetes-cluster
# See https://github.com/aws-actions/amazon-ecr-login
# See https://github.com/marketplace/actions/gradle-command
on:
push:
branches:
- master
- dockerize-frontend
- deploy-kubernetes
jobs:
build_frontend:
name: "frontend"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Run Yarn
run: cd frontend && yarn && yarn build
deploy:
needs: build_frontend
name: "Deploy"
runs-on: ubuntu-latest
steps:
- 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: eu-central-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Push frontend Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: codestar-interchange-frontend
IMAGE_TAG: ${{ github.sha }}
run: |
cd frontend
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: Build backend
uses: eskatos/gradle-command-action@v1
with:
build-root-directory: backend
wrapper-directory: backend
arguments: build
- name: Push backend Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: codestar-interchange-backend
IMAGE_TAG: ${{ github.sha }}
run: |
cd backend
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}
- name: Build data
uses: eskatos/gradle-command-action@v1
with:
build-root-directory: data
wrapper-directory: data
arguments: build
- name: Push data Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: codestar-interchange-data
IMAGE_TAG: ${{ github.sha }}
run: |
cd backend
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}
# K8S_SECRET is the YAML of the secret for a K8s service account
# See https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
# See https://github.com/Azure/k8s-set-context#service-account-approach
- uses: azure/k8s-set-context@v1
with:
method: service-account
k8s-url: ${{ secrets.K8S_URL }}
k8s-secret: ${{ secrets.K8S_SECRET }}
id: setcontext
- uses: Azure/k8s-deploy@v1
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
namespace: 'default'
manifests: |
aws/kubernetes/backend-deployment.yaml
aws/kubernetes/backend-service.yaml
images: '$ECR_REGISTRY/$ECR_REPOSITORY:latest'
kubectl-version: 'latest'