124 lines
5.1 KiB
YAML
124 lines
5.1 KiB
YAML
# =============================================================================
|
|
# Build and Push Docker Images to Forgejo Registry
|
|
# =============================================================================
|
|
# Triggers on push to main branch and pull requests
|
|
# Builds sequentially: backend, frontend, chat-service, openresty
|
|
# Single job to avoid rate limiting on git clone
|
|
# =============================================================================
|
|
|
|
name: Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
branches: [main, master]
|
|
workflow_dispatch: # Enable manual trigger
|
|
|
|
env:
|
|
REGISTRY: qbit.realms.pub
|
|
|
|
jobs:
|
|
build-all:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: docker:27
|
|
options: --privileged
|
|
steps:
|
|
- name: Install git
|
|
run: apk add --no-cache git
|
|
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --depth 1 --branch ${GITHUB_REF_NAME:-main} https://qbit.realms.pub/${GITHUB_REPOSITORY}.git .
|
|
|
|
- name: Login to Forgejo Registry
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
|
|
|
|
# =========================================================================
|
|
# Build Backend (C++/Drogon)
|
|
# =========================================================================
|
|
- name: Build Backend Image
|
|
run: |
|
|
echo "=== Building Backend ==="
|
|
docker build \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/backend:${{ github.sha }} \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/backend:latest \
|
|
./backend
|
|
|
|
- name: Push Backend Image
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/backend:${{ github.sha }}
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/backend:latest
|
|
|
|
# =========================================================================
|
|
# Build Frontend (SvelteKit)
|
|
# =========================================================================
|
|
- name: Build Frontend Image
|
|
run: |
|
|
echo "=== Building Frontend ==="
|
|
docker build \
|
|
--build-arg VITE_NAKAMA_SERVER_KEY=${{ secrets.NAKAMA_SERVER_KEY }} \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/frontend:${{ github.sha }} \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/frontend:latest \
|
|
./frontend
|
|
|
|
- name: Push Frontend Image
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/frontend:${{ github.sha }}
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/frontend:latest
|
|
|
|
# =========================================================================
|
|
# Build Chat Service
|
|
# =========================================================================
|
|
- name: Build Chat Service Image
|
|
run: |
|
|
echo "=== Building Chat Service ==="
|
|
docker build \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/chat-service:${{ github.sha }} \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/chat-service:latest \
|
|
./chat-service
|
|
|
|
- name: Push Chat Service Image
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/chat-service:${{ github.sha }}
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/chat-service:latest
|
|
|
|
# =========================================================================
|
|
# Build OpenResty (Nginx + Lua)
|
|
# =========================================================================
|
|
- name: Build OpenResty Image
|
|
run: |
|
|
echo "=== Building OpenResty ==="
|
|
docker build \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/openresty:${{ github.sha }} \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/openresty:latest \
|
|
./openresty
|
|
|
|
- name: Push OpenResty Image
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/openresty:${{ github.sha }}
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/openresty:latest
|
|
|
|
# =========================================================================
|
|
# Build Nakama (Game Server with Chess Modules)
|
|
# =========================================================================
|
|
- name: Build Nakama Image
|
|
run: |
|
|
echo "=== Building Nakama ==="
|
|
docker build \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/nakama:${{ github.sha }} \
|
|
-t ${{ env.REGISTRY }}/${{ github.repository }}/nakama:latest \
|
|
./nakama
|
|
|
|
- name: Push Nakama Image
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/nakama:${{ github.sha }}
|
|
docker push ${{ env.REGISTRY }}/${{ github.repository }}/nakama:latest
|