-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (108 loc) · 4.73 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
name: Build and deploy
on:
pull_request:
branches:
- master
push:
branches:
- master
workflow_dispatch:
env:
out_dir: ${{ vars.OUTPUT_DIR }}
tag: ${{ github.ref == format('refs/heads/{0}', 'master') && 'latest' || format('pr-{0}', github.event.pull_request.number) }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore tools
run: dotnet tool restore
- name: Push
run: echo "${{ github.token }}" | dotnet cake --target Push --tag ${tag}
deploy-test:
needs:
- build
runs-on: [host, ARM64]
environment: test
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Update DockerCompose
run: |
mkdir -p $out_dir
cp src/docker-compose.yml $out_dir
cd $out_dir
cat << EOF > docker-compose.override.yml
services:
server:
image: ghcr.io/${{ github.repository }}:${tag}-arm64v8
db-init:
image: ghcr.io/${{ github.repository }}:${tag}-arm64v8
EOF
cat << EOF > server.env
PILLSBOT__TELEGRAM__APITOKEN: ${{ secrets.PILLSBOT__TELEGRAM__APITOKEN }}
PILLSBOT__TELEGRAM__CHATID: "${{ secrets.PILLSBOT__TELEGRAM__CHATID }}"
PILLSBOT__REMINDER__INTERVAL: ${{ vars.PILLSBOT__REMINDER__INTERVAL }}
PILLSBOT__AI__LANGUAGES: ${{ secrets.PILLSBOT__AI__LANGUAGES }}
PILLSBOT__AI__PETNAMES: ${{ secrets.PILLSBOT__AI__PETNAMES }}
PILLSBOT__AI__PETGENDER: ${{ secrets.PILLSBOT__AI__PETGENDER }}
PILLSBOT__AI__MAXTOKENS: ${{ vars.PILLSBOT__AI__MAXTOKENS }}
PILLSBOT__AI__AZURE__ENDPOINT: ${{ secrets.PILLSBOT__AI__AZURE__ENDPOINT }}
PILLSBOT__AI__AZURE__KEY: ${{ secrets.PILLSBOT__AI__AZURE__KEY }}
PILLSBOT__AI__AZURE__DEPLOYMENTNAME: ${{ secrets.PILLSBOT__AI__AZURE__DEPLOYMENTNAME }}
APPLICATIONINSIGHTS__CONNECTIONSTRING: ${{ secrets.APPLICATIONINSIGHTS__CONNECTIONSTRING }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
CONNECTIONSTRINGS__PILLSBOTDBCONTEXT: Host=db;Database=${{ secrets.POSTGRES_DB }};Username=${{ secrets.POSTGRES_USER }};Password=${{ secrets.POSTGRES_PASSWORD }}
EOF
- name: Restart
run: |
cd $out_dir
docker compose up --detach --pull always --quiet-pull --remove-orphans --wait --wait-timeout 60
deploy-prod:
needs:
- build
- deploy-test
runs-on: [host, ARM64]
environment: prod
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Update DockerCompose
run: |
mkdir -p $out_dir
cp src/docker-compose.yml $out_dir
cd $out_dir
cat << EOF > docker-compose.override.yml
services:
server:
image: ghcr.io/${{ github.repository }}:${tag}-arm64v8
db-init:
image: ghcr.io/${{ github.repository }}:${tag}-arm64v8
EOF
cat << EOF > server.env
DOTNET_ENVIRONMENT: Development
PILLSBOT__TELEGRAM__APITOKEN: ${{ secrets.PILLSBOT__TELEGRAM__APITOKEN }}
PILLSBOT__TELEGRAM__CHATID: "${{ secrets.PILLSBOT__TELEGRAM__CHATID }}"
PILLSBOT__REMINDER__BEGINS: ${{ secrets.PILLSBOT__REMINDER__BEGINS }}
PILLSBOT__AI__ENABLED: ${{ vars.PILLSBOT__AI__ENABLED }}
PILLSBOT__AI__LANGUAGES: ${{ secrets.PILLSBOT__AI__LANGUAGES }}
PILLSBOT__AI__PETNAMES: ${{ secrets.PILLSBOT__AI__PETNAMES }}
PILLSBOT__AI__PETGENDER: ${{ secrets.PILLSBOT__AI__PETGENDER }}
PILLSBOT__AI__LOGLEVEL: ${{ vars.PILLSBOT__AI__LOGLEVEL }}
PILLSBOT__AI__MAXTOKENS: ${{ vars.PILLSBOT__AI__MAXTOKENS }}
PILLSBOT__AI__AZURE__ENDPOINT: ${{ secrets.PILLSBOT__AI__AZURE__ENDPOINT }}
PILLSBOT__AI__AZURE__KEY: ${{ secrets.PILLSBOT__AI__AZURE__KEY }}
PILLSBOT__AI__AZURE__DEPLOYMENTNAME: ${{ secrets.PILLSBOT__AI__AZURE__DEPLOYMENTNAME }}
APPLICATIONINSIGHTS__CONNECTIONSTRING: ${{ secrets.APPLICATIONINSIGHTS__CONNECTIONSTRING }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
CONNECTIONSTRINGS__PILLSBOTDBCONTEXT: Host=db;Database=${{ secrets.POSTGRES_DB }};Username=${{ secrets.POSTGRES_USER }};Password=${{ secrets.POSTGRES_PASSWORD }}
EOF
- name: Restart
run: |
cd $out_dir
docker compose up --detach --pull always --quiet-pull --remove-orphans --wait --wait-timeout 60