-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (78 loc) · 2.91 KB
/
build-and-deploy-web.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
name: build-and-deploy-web
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
name: Build images
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- name: Restore cached npm dependencies
id: cache-npm-deps
uses: actions/cache/restore@v4
with:
path: |
node_modules
~/.cache/Cypress # needed for the Cypress binary
key: npm-dependencies-${{ hashFiles('package.json') }}
- name: Install dependencies
run: pnpm install
if: steps.cache-npm-deps.outputs.cache-hit != 'true'
- name: Cache npm dependencies
uses: actions/cache/save@v4
with:
path: |
node_modules
~/.cache/Cypress # needed for the Cypress binary
key: npm-dependencies-${{ hashFiles('package.json') }}
# - name: Pull existing base image
# run: docker pull registry.digitalocean.com/maxdata/base:latest || echo "No existing image to pull"
- name: Build base image
run: npm run docker-base-linux
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
# 30min
run: doctl registry login --expiry-seconds 1800
- name: Push image to DO Container Registry
run: docker push registry.digitalocean.com/maxdata/base:latest
- name: Build image for web
env:
NEXT_TELEMETRY_DISABLED: true
NEXT_PUBLIC_API_HOST: https://api.linkerry.com
run: docker build -t linkerry/web --build-arg NEXT_PUBLIC_API_HOST=$NEXT_PUBLIC_API_HOST -f ./apps/web/Dockerfile . --platform=linux/amd64
- name: Tag web image
run: docker tag linkerry/web registry.digitalocean.com/maxdata/web:latest
- name: Push image to DO Container Registry
run: docker push registry.digitalocean.com/maxdata/web:latest
deploy:
runs-on: ubuntu-latest
name: Deploy web
needs: ['build']
steps:
- name: Connect to VPS and refresh docker compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.VPS_IP }}
username: root
key: ${{ secrets.SSH_PASSPHRASE_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
port: 22
script: |
cd linkerry.com/
docker compose pull
docker compose up -d --no-deps --build web
docker image prune -f
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
# 30min
run: doctl registry login --expiry-seconds 1800
# - name: Clear DO container registry
# run: doctl registry garbage-collection start --force linkerry