-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (48 loc) · 2.09 KB
/
Copy pathdeploy.yml
File metadata and controls
51 lines (48 loc) · 2.09 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
name: Deploy
# Autodeploy: SSH to the host and rebuild the compose stack in place (matches the
# existing build-on-server model). Trigger on push to main, plus manual dispatch
# for the first/controlled run.
#
# Required repo secrets:
# DEPLOY_HOST - server hostname or IP
# DEPLOY_USER - SSH user (e.g. root)
# DEPLOY_KEY - SSH private key with access to that user
# DEPLOY_PATH - absolute path to the monorepo checkout (e.g. /root/codevideo-api)
# DOCKERHUB_USERNAME / DOCKERHUB_TOKEN - optional; only needed to pull the
# render-worker image (fullstackcraft/codevideo-cli) if that repo is private.
#
# Pre-reqs before enabling (see DEPLOYMENT.md):
# - commit the server's local nginx/conf/api.fullstackcraft.com.conf edit, or
# `git pull --ff-only` below will refuse to fast-forward and the deploy fails.
# - point the server checkout at this restructured monorepo (single checkout,
# no sibling ../codevideo-genie or ../codevideo-tts needed anymore).
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: production-deploy
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy over SSH (build on server)
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
script: |
set -euo pipefail
cd "${{ secrets.DEPLOY_PATH }}"
git fetch origin main
git pull --ff-only origin main
# Authenticate to Docker Hub only if creds are set (needed when the
# codevideo-cli image repo is private); otherwise the public pull works.
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ] && [ -n "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
fi
docker compose pull # fetch the pinned render-worker image
docker compose up -d --build
docker image prune -f