Skip to content

Refactor NoteBuilder to be reusable #644

Refactor NoteBuilder to be reusable

Refactor NoteBuilder to be reusable #644

Workflow file for this run

name: Build and Deploy
on:
push:
env:
CR_REGISTRY: ${{ secrets.YC_CR_REGISTRY }}
CR_REPOSITORY: food-diary
IMAGE_TAG: ${{ github.sha }}
jobs:
backend:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: 'src/backend'
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run unit tests
run: dotnet test tests/FoodDiary.UnitTests --no-restore --verbosity normal
- name: Run component tests
run: dotnet test tests/FoodDiary.ComponentTests --no-restore --verbosity normal
frontend:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: 'src/frontend'
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.16.0'
- name: Install
run: yarn install
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Test
run: yarn test
e2e-tests:
needs:
- backend
- frontend
runs-on: ubuntu-22.04
timeout-minutes: 10
defaults:
run:
working-directory: 'tests'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Start containers
run: docker compose up -d --build
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '18.16.0'
- name: Install dependencies
run: yarn
- name: Lint
run: yarn lint
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: tests/playwright-report/
retention-days: 30
- name: Stop containers
if: always()
run: docker compose down
run-migrations:
runs-on: ubuntu-22.04
needs: e2e-tests
if: ${{ github.ref == 'refs/heads/main' }}
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-22.04
needs: run-migrations
if: ${{ github.ref == 'refs/heads/main' }}
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-22.04
needs: build-and-push-image
if: ${{ github.ref == 'refs/heads/main' }}
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