Skip to content

Deploy server

Deploy server #21

Workflow file for this run

name: Deploy server
on:
workflow_dispatch:
inputs:
vm-name:
default: "-test"
type: choice
description: "VM name, empty string - production"
options:
- "-test"
- ""
env:
BACKEND_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/syncwatch-backend${{ inputs.vm-name }}:${{ github.sha }}
NGINX_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/syncwatch-nginx${{ inputs.vm-name }}:${{ github.sha }}
jobs:
build-backend:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: "./package-lock.json"
- name: Install dependencies
run: npm ci
- name: Build server
run: npm run build -w syncwatch-server
- name: Copy package-lock.json to npm workspace
run: cp package-lock.json ./packages/syncwatch-server/package-lock.json
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Build Backend
uses: docker/build-push-action@v5
with:
context: ./packages/syncwatch-server/
file: ./packages/syncwatch-server/Dockerfile
push: true
tags: ${{ env.BACKEND_IMAGE }}
build-nginx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Build Nginx for together composing
uses: docker/build-push-action@v5
with:
context: ./nginx
file: ./nginx/Dockerfile
push: true
tags: ${{ env.NGINX_IMAGE }}
update-yc:
runs-on: ubuntu-latest
needs: [build-backend, build-nginx]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy COI VM
id: deploy-coi
uses: yc-actions/[email protected]
env:
BACKEND_IMAGE: ${{ env.BACKEND_IMAGE }}
NGINX_IMAGE: ${{ env.NGINX_IMAGE }}
YC_VM_SSH: ${{ secrets.YC_VM_SSH }}
YC_VM_USERNAME: ${{ secrets.YC_VM_USERNAME }}
YC_SA_JSON_CREDENTIALS: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
YC_FOLDER_ID: ${{ secrets.YC_FOLDER_ID }}
YC_CERTIFICATE_ID: ${{ secrets.YC_CERTIFICATE_ID }}
with:
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
folder-id: ${{ secrets.YC_FOLDER_ID }}
vm-name: syncwatch-sockets${{ inputs.vm-name }}
vm-service-account-id: ${{ secrets.YC_SERVICE_ACCOUNT_ID }}
vm-cores: 2
vm-platform-id: "standard-v2"
vm-memory: 1024Mb
vm-disk-size: 30Gb
vm-core-fraction: 5
vm-subnet-id: ${{ secrets.YC_SUBNET_ID }}
docker-compose-path: "./yandex-cloud/docker-compose.yc.yaml"
user-data-path: "./yandex-cloud/user-data.yaml"