Merge pull request #241 from DocShow-AI/dev #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |