-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (34 loc) · 2.32 KB
/
build-and-deploy.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
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build and Push Frontend Docker Image
run: |
docker build --build-arg VITE_API_URL=${{ secrets.VITE_API_URL }} --build-arg VITE_APP_ENV=${{ secrets.VITE_APP_ENV }} -t registry.digitalocean.com/docshow-ai/frontend-prod:${{ github.sha }} -f frontend/Dockerfile.prod frontend/
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.digitalocean.com -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
docker push registry.digitalocean.com/docshow-ai/frontend-prod:${{ github.sha }}
- name: Build and Push Backend Docker Image
run: |
docker build -t registry.digitalocean.com/docshow-ai/backend-prod:${{ github.sha }} -f backend/Dockerfile.prod backend/
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.digitalocean.com -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
docker push registry.digitalocean.com/docshow-ai/backend-prod:${{ github.sha }}
- name: Build and Push Migration Docker Image
run: |
docker build -t registry.digitalocean.com/docshow-ai/migration-prod:${{ github.sha }} -f backend/Dockerfile.migration backend/
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.digitalocean.com -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
docker push registry.digitalocean.com/docshow-ai/migration-prod:${{ github.sha }}
- name: Set up Kubectl and Update Deployment
run: |
echo "${{ secrets.KUBECONFIG_SECRET }}" | base64 --decode > kubeconfig.yml
kubectl --kubeconfig=kubeconfig.yml set image deployment/frontend-deployment frontend=registry.digitalocean.com/docshow-ai/frontend-prod:${{ github.sha }}
kubectl --kubeconfig=kubeconfig.yml set image deployment/backend-deployment backend=registry.digitalocean.com/docshow-ai/backend-prod:${{ github.sha }}
kubectl --kubeconfig=kubeconfig.yml delete job alembic-migration --ignore-not-found
sed -i 's|registry.digitalocean.com/docshow-ai/migration-prod:latest|registry.digitalocean.com/docshow-ai/migration-prod:'"${{ github.sha }}"'|' k8s/migration-job.yaml
kubectl --kubeconfig=kubeconfig.yml apply -f k8s/migration-job.yaml