Add Gitea Actions workflow for auto-build on push; update docker-compose.yml
Build & Deploy / build-and-deploy (push) Has been cancelled
Build & Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
# This workflow builds and deploys Dostalgia whenever code is pushed to main.
|
||||||
|
# Requires a Gitea Actions runner registered on the host with Docker socket access.
|
||||||
|
# See: https://docs.gitea.com/usage/actions
|
||||||
|
|
||||||
|
name: Build & Deploy
|
||||||
|
run-name: Build ${{ gitea.sha.substring(0, 7) }}
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: dostalgia
|
||||||
|
CONTAINER_NAME: dostalgia
|
||||||
|
HOST_PORT: 8765
|
||||||
|
DATA_VOLUME: /opt/data/workspace/dostalgia/data
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t ${{ env.IMAGE_NAME }}:${{ gitea.sha }} .
|
||||||
|
docker tag ${{ env.IMAGE_NAME }}:${{ gitea.sha }} ${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
- name: Stop and remove old container
|
||||||
|
run: |
|
||||||
|
docker stop ${{ env.CONTAINER_NAME }} 2>/dev/null || true
|
||||||
|
docker rm ${{ env.CONTAINER_NAME }} 2>/dev/null || true
|
||||||
|
|
||||||
|
- name: Start new container
|
||||||
|
run: |
|
||||||
|
docker run -d \
|
||||||
|
--name ${{ env.CONTAINER_NAME }} \
|
||||||
|
--restart unless-stopped \
|
||||||
|
-p ${{ env.HOST_PORT }}:8765 \
|
||||||
|
-v ${{ env.DATA_VOLUME }}:/data \
|
||||||
|
-e TWITCH_CLIENT_ID='${{ secrets.TWITCH_CLIENT_ID }}' \
|
||||||
|
-e TWITCH_CLIENT_SECRET='${{ secrets.TWITCH_CLIENT_SECRET }}' \
|
||||||
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
- name: Wait for health check
|
||||||
|
run: |
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if curl -sf http://localhost:${{ env.HOST_PORT }}/api/health >/dev/null 2>&1; then
|
||||||
|
echo "✅ Dostalgia is running!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "❌ Health check failed"
|
||||||
|
docker logs ${{ env.CONTAINER_NAME }} --tail 20
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Clean up old images
|
||||||
|
run: docker image prune -f --filter "until=24h"
|
||||||
+2
-2
@@ -7,8 +7,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
environment:
|
environment:
|
||||||
- DOSTALGIA_DATA=/data
|
- DOSTALGIA_DATA_DIR=/data
|
||||||
# IGDB credentials (optional):
|
# IGDB credentials — set these for auto-scrape to work:
|
||||||
# - TWITCH_CLIENT_ID=your_client_id
|
# - TWITCH_CLIENT_ID=your_client_id
|
||||||
# - TWITCH_CLIENT_SECRET=your_client_secret
|
# - TWITCH_CLIENT_SECRET=your_client_secret
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
Reference in New Issue
Block a user