Merge pull request #379 from codekids-vt/loops-book-components #106
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: Deploy Backend | |
on: | |
push: | |
branches: | |
- main # or any branch you want to deploy from | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Steps will be defined here | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Echo secrets | |
run: | | |
touch ./backend/.env | |
echo '${{ secrets.BACKEND_ENV }}' >> ./backend/.env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Build and Push | |
uses: docker/build-push-action@v2 | |
with: | |
context: backend | |
file: ./backend/Dockerfile | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/codekids-backend:${{ github.sha }} | |
- name: Set up Kubectl | |
uses: azure/setup-kubectl@v1 | |
with: | |
version: 'latest' | |
- name: Update Kubernetes Deployment | |
run: | | |
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ./kubeconfig | |
export KUBECONFIG=./kubeconfig | |
kubectl set image deployment/codekids-backend codekids-backend=ghcr.io/${{ github.repository_owner }}/codekids-backend:${{ github.sha }} --namespace codekids-app |