-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (142 loc) · 5.15 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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