-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (69 loc) · 2.2 KB
/
dev-build-deploy-web.yml
File metadata and controls
80 lines (69 loc) · 2.2 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
name: Deploy Web to Development
on:
push:
branches:
- dev
paths:
- "apps/web/**"
- "infra/docker-compose.web.yml"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-and-push:
name: Build and Push Docker Image to GHCR
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
run: |
docker build \
--platform linux/amd64 \
-t ghcr.io/${{ github.repository_owner }}/core-web:dev \
--file ./apps/web/Dockerfile \
--target prod \
./apps/web
- name: Push Docker image
run: |
docker push ghcr.io/${{ github.repository_owner }}/core-web:dev
deploy:
name: Deploy to Development Server
runs-on: ubuntu-latest
needs: [build-and-push]
steps:
- name: SSH proxy commmand
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.WEB_HOST }}
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
# password: ${{ secrets.WEB_PASSWORD }}
script: |
cd /root/core/infra
git fetch
git checkout dev
git reset --hard origin/dev
git pull
export INFISICAL_TOKEN=$(infisical login \
--method=universal-auth \
--client-id='${{ secrets.INFISICAL_CLIENT_ID }}' \
--client-secret='${{ secrets.INFISICAL_CLIENT_SECRET }}' \
--silent \
--plain)
infisical export \
--token=$INFISICAL_TOKEN \
--env=dev \
--format=dotenv \
--path="/web" \
--projectId='${{ secrets.INFISICAL_PROJECT_ID }}' \
> ./secrets/.env.dev.web
docker compose -f docker-compose.web.yml pull web-dev caddy
docker compose -f docker-compose.web.yml up -d --no-deps --force-recreate web-dev caddy