Skip to content

Deploy API server

Deploy API server #4

name: Deploy API server
on:
workflow_dispatch:
inputs:
name:
description: 'Deploy Implementer'
default: 'World'
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v3
- name: Login to Yandex Cloud Container Registry
id: login-cr
uses: yc-actions/yc-cr-login@v1
with:
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
- name: Build docker image
run: docker build . --file docker/server/Dockerfile --tag cr.yandex/crpqcg70aaep5tihmd33/common-backend-server:latest
- name: Push docker image to Yandex.Cloud registry
run: docker push cr.yandex/crpqcg70aaep5tihmd33/common-backend-server:latest
- name: Wait until Yandex.Cloud process new docker image
uses: jakejarvis/[email protected]
with:
time: '30s'
- name: Substitute the real value of variables
env:
TOKEN_ACCESS_SIGN_SECRET: ${{ secrets.TOKEN_ACCESS_SIGN_SECRET }}
TOKEN_REFRESH_SIGN_SECRET: ${{ secrets.TOKEN_REFRESH_SIGN_SECRET }}
TOKEN_ISSUER: ${{ secrets.TOKEN_ISSUER }}
MONGODB_URL: ${{ secrets.MONGODB_URL }}
MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }}
run: |
sed -i "s|{{TOKEN_ACCESS_SIGN_SECRET}}|$TOKEN_ACCESS_SIGN_SECRET|g" ./k8s/server/deployment.yaml
sed -i "s|{{TOKEN_REFRESH_SIGN_SECRET}}|$TOKEN_REFRESH_SIGN_SECRET|g" ./k8s/server/deployment.yaml
sed -i "s|{{TOKEN_ISSUER}}|$TOKEN_ISSUER|g" ./k8s/server/deployment.yaml
sed -i "s|{{MONGODB_URL}}|$MONGODB_URL|g" ./k8s/server/deployment.yaml
sed -i "s|{{MONGODB_DATABASE}}|$MONGODB_DATABASE|g" ./k8s/server/deployment.yaml
- name: Deploy to k8s
uses: actions-hub/[email protected]
env:
KUBE_CONFIG: ${{ secrets.K8S_CONFIG }}
with:
args: apply -f ./k8s/server/deployment.yaml