Deploy server #13
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 server | |
on: | |
workflow_dispatch: | |
inputs: | |
vm-name: | |
default: "-test" | |
type: string | |
description: "VM name, empty string - production" | |
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-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: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
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" |