-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (126 loc) · 5.5 KB
/
deploy.yaml
File metadata and controls
141 lines (126 loc) · 5.5 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# =============================================================================
# Vibeyard - Build and Deploy to Kubernetes
# =============================================================================
# Builds Docker images for app, migrator, and worker, then deploys to EKS
# =============================================================================
name: deploy-vibeyard
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
environment: prod
runs-on: ubuntu-latest
env:
HELM_FILE: deploy/prod/values.yaml
WORKER_HELM_FILE: deploy/prod/worker-values.yaml
REGION: us-east-1
CLUSTER_NAME: maker-prod
NAMESPACE: vibeyard
SERVICE_NAME: vibeyard
AWS_ECR_NAME: vibeyard-prod
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
uses: docker/setup-buildx-action@v3
- name: Extract commit hash
id: vars
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push app image
id: build-app
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
target: runner
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:app-${{ steps.vars.outputs.sha_short }}
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:app-latest
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:cache-app
cache-to: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:cache-app,mode=max
- name: Build and push migrator image
id: build-migrator
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
target: migrator
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:migrator-${{ steps.vars.outputs.sha_short }}
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:migrator-latest
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:cache-app
- name: Build and push worker image
id: build-worker
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
target: worker
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:worker-${{ steps.vars.outputs.sha_short }}
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:worker-latest
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }}:cache-app
- name: Replace variables in Helm values files
if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ steps.vars.outputs.sha_short }}
run: |
sed -i 's|${ECR_REGISTRY}|'"$ECR_REGISTRY"'|g' $HELM_FILE
sed -i 's|${IMAGE_TAG}|'"$IMAGE_TAG"'|g' $HELM_FILE
sed -i 's|${ECR_REGISTRY}|'"$ECR_REGISTRY"'|g' $WORKER_HELM_FILE
sed -i 's|${IMAGE_TAG}|'"$IMAGE_TAG"'|g' $WORKER_HELM_FILE
- name: Configure kubectl
if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }}
run: |
aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.REGION }}
- name: Deploy main app to Kubernetes
id: deploy-app
if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }}
uses: bitovi/github-actions-deploy-eks-helm@v1.2.10
with:
cluster-name: ${{ env.CLUSTER_NAME }}
config-files: ${{ env.HELM_FILE }}
chart-path: techops-services/common
namespace: ${{ env.NAMESPACE }}
timeout: 5m0s
name: ${{ env.SERVICE_NAME }}
chart-repository: https://techops-services.github.io/helm-charts
version: 0.0.33
atomic: true
- name: Deploy worker to Kubernetes
id: deploy-worker
if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }}
uses: bitovi/github-actions-deploy-eks-helm@v1.2.10
with:
cluster-name: ${{ env.CLUSTER_NAME }}
config-files: ${{ env.WORKER_HELM_FILE }}
chart-path: techops-services/common
namespace: ${{ env.NAMESPACE }}
timeout: 5m0s
name: ${{ env.SERVICE_NAME }}-worker
chart-repository: https://techops-services.github.io/helm-charts
version: 0.0.33
atomic: true