-
Notifications
You must be signed in to change notification settings - Fork 7
82 lines (72 loc) · 2.65 KB
/
Copy pathdeploy.yml
File metadata and controls
82 lines (72 loc) · 2.65 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
name: Deploy ui
on:
workflow_dispatch: {}
jobs:
build_and_deploy:
if: github.actor == 'maslianok'
environment: production
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
# 1. Check out the code
- name: Check out repository
uses: actions/checkout@v4
# 2. Set up Node (v18) and install pnpm
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install pnpm
run: |
npm install -g corepack@latest
corepack enable
corepack prepare pnpm@10 --activate
# 4. Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
push: true
tags: ghcr.io/gitranks/gitranks-ui:latest
build-args: |
NEXT_PUBLIC_POSTHOG_KEY=${{ vars.NEXT_PUBLIC_POSTHOG_KEY }}
NEXT_PUBLIC_URI=${{ vars.NEXT_PUBLIC_URI }}
INTERNAL_JWT_SECRET=${{ secrets.INTERNAL_JWT_SECRET }}
URI_GITRANKS=${{ vars.URI_GITRANKS }}
# 4. SSH to droplet and deploy
- name: SSH to droplet and deploy
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ vars.DO_IP }}
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo ${{ secrets.GHCR_PAT }} | docker login ghcr.io -u maslianok --password-stdin
docker pull ghcr.io/gitranks/gitranks-ui:latest
docker stop gitranks-ui || true
docker rm gitranks-ui || true
docker run -d \
--restart=always \
--name gitranks-ui \
-e MONGODB_URI_AUTH='${{ secrets.MONGODB_URI_AUTH }}' \
-e INTERNAL_JWT_SECRET='${{ secrets.INTERNAL_JWT_SECRET }}' \
-e AUTH_SECRET='${{ secrets.AUTH_SECRET }}' \
-e AUTH_GITHUB_SECRET='${{ secrets.AUTH_GITHUB_SECRET }}' \
-e URI_GITRANKS='${{ vars.URI_GITRANKS }}' \
-e AUTH_GITHUB_ID='${{ vars.AUTH_GITHUB_ID }}' \
-e AUTH_URL='${{ vars.AUTH_URL }}' \
-e AUTH_TRUST_HOST=true \
-e NEXT_PUBLIC_URI='${{ vars.NEXT_PUBLIC_URI }}' \
-e NEXT_PUBLIC_POSTHOG_KEY='${{ vars.NEXT_PUBLIC_POSTHOG_KEY }}' \
-p 3000:3000 \
ghcr.io/gitranks/gitranks-ui:latest