-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (113 loc) · 4.36 KB
/
deploy-ducksmanager.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
name: deploy-ducksmanager
on:
workflow_dispatch:
push:
branches:
- "master"
jobs:
deploy-dm:
runs-on: ubuntu-latest
environment: production
steps:
- uses: oven-sh/setup-bun@v1
- name: Check out repository
uses: actions/checkout@master
- name: Download web .env file
uses: nicklasfrahm/scp-action@main
with:
direction: download
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: /home/bperel/workspace/DucksManager2/apps/web/.env.prod.local
target: apps/web/.env
- name: Download api .env file
uses: nicklasfrahm/scp-action@main
with:
direction: download
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: /home/bperel/workspace/DucksManager2/packages/api/.env.prod.local
target: packages/api/.env
- name: Download prisma-schemas .env file
uses: nicklasfrahm/scp-action@main
with:
direction: download
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: /home/bperel/workspace/DucksManager2/packages/prisma-clients/.env.prod.local
target: packages/prisma-schemas/.env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: bperel
password: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Install dependencies
run: pnpm -r install
- name: Build api bundle
run: pnpm build:api
- name: Build and push api
uses: docker/build-push-action@v5
with:
context: .
file: packages/api/Dockerfile
platforms: linux/x86_64
push: true
cache-from: type=registry,ref=ghcr.io/bperel/ducksmanager-api:buildcache
cache-to: type=registry,ref=ghcr.io/bperel/ducksmanager-api:buildcache,mode=max
tags: |
ghcr.io/bperel/ducksmanager-api:websocket
- name: Build web
run: pnpm build:web
- name: Build and push web
uses: docker/build-push-action@v5
with:
context: .
file: apps/web/Dockerfile
platforms: linux/x86_64
push: true
cache-from: type=registry,ref=ghcr.io/bperel/ducksmanager-web:buildcache
cache-to: type=registry,ref=ghcr.io/bperel/ducksmanager-web:buildcache,mode=max
tags: |
ghcr.io/bperel/ducksmanager-web:websocket
- name: Upload docker-compose.yml file
uses: nicklasfrahm/[email protected]
with:
direction: upload
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: apps/web/docker-compose.yml
target: /home/bperel/workspace/DucksManager2/docker-compose.yml
- name: Recreate containers
uses: appleboy/[email protected]
env:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
command_timeout: 2m
envs: DOCKER_REGISTRY_TOKEN_DM
script: |
cd workspace/DucksManager2
echo `grep GITHUB_TOKEN .env | cut -d'=' -f2` | docker login ghcr.io -u bperel --password-stdin
docker compose pull && docker compose up -d --force-recreate web-websocket api-websocket sentry-relay