# 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: Verify container is running run: | sleep 5 STATUS=$(docker inspect -f '{{.State.Status}}' ${{ env.CONTAINER_NAME }}) if [ "$STATUS" = "running" ]; then echo "✅ Dostalgia container is running" echo "--- last logs ---" docker logs ${{ env.CONTAINER_NAME }} --tail 5 echo "✅ Dostalgia deployed!" else echo "❌ Container status: $STATUS" docker logs ${{ env.CONTAINER_NAME }} --tail 30 exit 1 fi - name: Clean up old images run: docker image prune -f --filter "until=24h"