Skip to content

Deploy

Deploy #137

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
env:
CR_REGISTRY: ${{ secrets.YC_CR_REGISTRY }}
CR_REPOSITORY: food-diary
IMAGE_TAG: ${{ github.sha }}
jobs:
run-migrations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
- name: Run migrator
run: dotnet run --configuration Release --project src/backend/src/FoodDiary.Migrator/FoodDiary.Migrator.csproj "${{ secrets.Migrator_DatabaseConnectionString }}"
build-and-push-image:
runs-on: ubuntu-latest
needs: run-migrations
steps:
- name: Checkout to the branch
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.YC_SA_JSON_CREDENTIALS }}
- name: Build, tag, and push image to Yandex Cloud Container Registry
run: |
docker build -t cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG .
docker push cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
deploy:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Deploy Serverless Container
id: deploy-sls-container
uses: yc-actions/yc-sls-container-deploy@v2
with:
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
container-name: ${{ env.CR_REPOSITORY }}
folder-id: ${{ secrets.YC_FOLDER_ID }}
public: true
revision-image-url: cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_REPOSITORY }}:${{ env.IMAGE_TAG }}
revision-service-account-id: ${{ secrets.YC_REVISION_SERVICE_ACCOUNT_ID }}
revision-cores: 1
revision-memory: 512Mb
revision-core-fraction: 100
revision-concurrency: 2
revision-execution-timeout: 10
revision-provisioned: 0
revision-env: |
App__ForwardHttpsSchemeManuallyForAllRequests=true
App__Logging__WriteLogsInJsonFormat=true
App__Logging__UseYandexCloudLogsFormat=true
revision-secrets: |
Auth__AllowedEmails__0=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/auth-allowed-emails
Google__ExportFolderId=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/google-export-folder-id
ConnectionStrings__Default=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/database-connection-string
GoogleAuth__ClientId=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/google-client-id
GoogleAuth__ClientSecret=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/google-client-secret
Integrations__OpenAI__BaseUrl=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/integrations-openai-base-url
Integrations__OpenAI__ApiKey=${{ vars.YC_REVISION_SECRETS_ID }}/${{ vars.YC_REVISION_SECRETS_VERSION }}/integrations-openai-api-key