ci: use docker run with correct volume path instead of compose file
Build & Deploy / build-and-deploy (push) Successful in 11s
Build & Deploy / build-and-deploy (push) Successful in 11s
The runner container can't access the compose file path on the host. Use the compose file's parameters (network: dockernet, volume: /mnt/cache/appdata/dostalgia) directly in docker run instead.
This commit is contained in:
+20
-14
@@ -1,7 +1,7 @@
|
|||||||
# This workflow builds and deploys Dostalgia whenever code is pushed to main.
|
# This workflow builds and deploys Dostalgia whenever code is pushed to main.
|
||||||
# Uses docker-compose at /unraid/dostalgia/compose.yaml (mounted into the
|
# The runner has Docker socket access so it can manage containers on the host.
|
||||||
# runner container from the host's /appdata/dockhand/stacks/unraid/dostalgia).
|
# Parameters match the docker-compose at:
|
||||||
# Requires a Gitea Actions runner registered on the host with Docker socket access.
|
# /appdata/dockhand/stacks/unraid/dostalgia/compose.yaml
|
||||||
# See: https://docs.gitea.com/usage/actions
|
# See: https://docs.gitea.com/usage/actions
|
||||||
|
|
||||||
name: Build & Deploy
|
name: Build & Deploy
|
||||||
@@ -13,7 +13,8 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: dostalgia
|
IMAGE_NAME: dostalgia
|
||||||
COMPOSE_DIR: /unraid/dostalgia
|
CONTAINER_NAME: dostalgia
|
||||||
|
DATA_VOLUME: /mnt/cache/appdata/dostalgia
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
@@ -28,27 +29,32 @@ jobs:
|
|||||||
docker build -t ${{ env.IMAGE_NAME }}:${{ gitea.sha }} .
|
docker build -t ${{ env.IMAGE_NAME }}:${{ gitea.sha }} .
|
||||||
docker tag ${{ env.IMAGE_NAME }}:${{ gitea.sha }} ${{ env.IMAGE_NAME }}:latest
|
docker tag ${{ env.IMAGE_NAME }}:${{ gitea.sha }} ${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
- name: Deploy via docker-compose
|
- name: Deploy container
|
||||||
run: |
|
run: |
|
||||||
cd "${{ env.COMPOSE_DIR }}"
|
docker stop ${{ env.CONTAINER_NAME }} 2>/dev/null || true
|
||||||
docker compose up -d
|
docker rm ${{ env.CONTAINER_NAME }} 2>/dev/null || true
|
||||||
|
docker run -d \
|
||||||
|
--name ${{ env.CONTAINER_NAME }} \
|
||||||
|
--restart unless-stopped \
|
||||||
|
--network dockernet \
|
||||||
|
-p 8765:8765/tcp \
|
||||||
|
-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
|
- name: Verify container is running
|
||||||
run: |
|
run: |
|
||||||
sleep 5
|
sleep 5
|
||||||
CONTAINER_NAME=$(docker compose -f "${{ env.COMPOSE_DIR }}/compose.yaml" ps -q dostalgia 2>/dev/null || echo "dostalgia")
|
STATUS=$(docker inspect -f '{{.State.Status}}' ${{ env.CONTAINER_NAME }})
|
||||||
if [ -z "$CONTAINER_NAME" ] || [ "$CONTAINER_NAME" = "dostalgia" ]; then
|
|
||||||
CONTAINER_NAME="dostalgia"
|
|
||||||
fi
|
|
||||||
STATUS=$(docker inspect -f '{{.State.Status}}' "$CONTAINER_NAME" 2>/dev/null || docker inspect -f '{{.State.Status}}' dostalgia)
|
|
||||||
if [ "$STATUS" = "running" ]; then
|
if [ "$STATUS" = "running" ]; then
|
||||||
echo "✅ Dostalgia container is running"
|
echo "✅ Dostalgia container is running"
|
||||||
echo "--- last logs ---"
|
echo "--- last logs ---"
|
||||||
docker logs dostalgia --tail 5
|
docker logs ${{ env.CONTAINER_NAME }} --tail 5
|
||||||
echo "✅ Dostalgia deployed!"
|
echo "✅ Dostalgia deployed!"
|
||||||
else
|
else
|
||||||
echo "❌ Container status: $STATUS"
|
echo "❌ Container status: $STATUS"
|
||||||
docker logs dostalgia --tail 30
|
docker logs ${{ env.CONTAINER_NAME }} --tail 30
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user