Skip to content

Deploy Backend

Deploy Backend #112

name: Deploy Backend
on:
workflow_dispatch:
inputs:
tag:
required: true
type: string
description: Docker image tag for container registry
env:
IMAGE_NAME: backend
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Yandex Cloud Container Registry
id: login-cr
uses: yc-actions/yc-cr-login@v2
with:
yc-sa-json-credentials: ${{ secrets.CI_REGISTRY_KEY }}
- name: Set production settings
run: touch ./conf/prod.yaml && echo '${{ secrets.PRODUCTION_SETTINGS }}' > ./conf/prod.yaml
- name: Build, tag, and push image to Yandex Cloud Container Registry
run: |
docker build -t ${{ secrets.CI_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }} .
docker push ${{ secrets.CI_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }}
deploy:
runs-on: ubuntu-latest
container: gcr.io/cloud-builders/kubectl:latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Update deployment image
run: |
kubectl config set-cluster k8s --server="${{ secrets.KUBE_URL }}" --insecure-skip-tls-verify=true
kubectl config set-credentials admin --token="${{ secrets.KUBE_TOKEN }}"
kubectl config set-context default --cluster=k8s --user=admin
kubectl config use-context default
sed -i "s,__VERSION__,${{ secrets.CI_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }}," ./infra/k8s/questspace/questspace-backend.yaml
kubectl apply -f ./infra/k8s/questspace/questspace-backend.yaml