-
Notifications
You must be signed in to change notification settings - Fork 5
86 lines (75 loc) · 2.71 KB
/
Copy pathdeploy.yml
File metadata and controls
86 lines (75 loc) · 2.71 KB
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
name: Build & Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
name: Build & push images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Compute lowercase image namespace
id: image_vars
shell: bash
run: echo "owner_lc=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build & push API
uses: docker/build-push-action@v6
with:
context: .
file: apps/api/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ steps.image_vars.outputs.owner_lc
}}/ethsec-api:latest,${{ env.REGISTRY }}/${{
steps.image_vars.outputs.owner_lc }}/ethsec-api:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build & push Web
uses: docker/build-push-action@v6
with:
context: .
file: apps/web/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ steps.image_vars.outputs.owner_lc
}}/ethsec-web:latest,${{ env.REGISTRY }}/${{
steps.image_vars.outputs.owner_lc }}/ethsec-web:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VITE_API_BASE_URL=
VITE_BADGE_CONTRACT=${{ secrets.BADGE_CONTRACT }}
VITE_CHAIN_ID=${{ secrets.CHAIN_ID }}
VITE_RPC_URL=${{ secrets.RPC_URL }}
VITE_WALLETCONNECT_PROJECT_ID=${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }}
VITE_ENCRYPTION_PUBLIC_KEY_HEX=${{ secrets.ENCRYPTION_PUBLIC_KEY_HEX }}
deploy:
name: Deploy to VPS
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Pull & restart stack
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd ~/ethsec-voting-badge
git pull --ff-only
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --force-recreate --remove-orphans
docker image prune -f