kind: pipeline type: docker # All steps will run in Docker containers. name: update-and-restart-discord-bot # A descriptive name for the pipeline. when: - branch: main # This pipeline triggers on pushes to the 'main' branch. event: push steps: - name: pull-latest-source # Step 1: Pull the latest code from Gitea. image: alpine/git # A lightweight image that includes the 'git' command. volumes: # Mount your bot's source code directory with read-write permissions. # This is crucial for 'git pull' to update the files on your host machine. - /home/gary/Discord/Acrybot:/app:rw # ':rw' ensures read-write access. commands: - echo "--- Pulling latest source code from Git ---" - cd /app # Navigate to the mounted project directory. # Configure Git to trust the mounted directory to avoid 'unsafe repository' warnings. - git config --global --add safe.directory /app - git pull # Pulls the latest changes from the tracking branch. - echo "Source code updated." - name: manage-bot-containers # Step 2: Manage your bot's Docker containers. # Changed image to 'docker:latest' to use the unhyphenated 'docker compose' image: docker:latest volumes: # Mount the Docker socket from the host to allow control over host Docker daemon. - /var/run/docker.sock:/var/run/docker.sock # Mount your Docker Compose project directory into the container. - /home/gary/Discord/Acrybot:/app environment: # IMPORTANT: Explicitly set the Docker Compose project name to lowercase. # This ensures containers are managed with the 'acrybot' prefix, # matching your existing containers. COMPOSE_PROJECT_NAME: acrybot # Changed to lowercase 'acrybot' commands: - echo "--- Building 'python-app' image without cache to ensure latest code ---" # Explicitly build the image for 'python-app' with --no-cache - docker compose build --no-cache python-app - echo "--- Stopping Discord bot service python-app ---" # Stop the specific Discord bot service using the unhyphenated 'docker compose'. - docker compose stop python-app - echo "--- Bringing Discord bot service up python-app ---" # Bring the specific Discord bot service back up using the unhyphenated 'docker compose'. # '--build' is no longer needed here as it was already forced by 'docker compose build --no-cache'. - docker compose up -d python-app - echo "--- Verifying bot status ---" # Directly check the status of the service using docker compose ps - docker compose ps python-app - echo "--- Logs of Discord bot service ---" # Fetch the logs of the bot service using docker compose logs - docker compose logs python-app