Update
Deploy Stack via Docker Compose / deploy-compose (push) Has been cancelled

This commit is contained in:
2026-06-23 20:05:25 -04:00
parent 54110854f0
commit 653e71cbdc
+10 -47
View File
@@ -1,61 +1,24 @@
name: Build and Deploy App with Watchtower name: Deploy Stack via Docker Compose
on: on:
push: push:
branches: [ main ] branches: [ main ]
jobs: jobs:
build-and-deploy: deploy-compose:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Run a sidecar Docker daemon container inside the runner environment
services:
docker:
image: docker:27-dind
privileged: true
volumes:
- /var/run:/var/run
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Recreate Environment File
uses: docker/setup-buildx-action@v3 # This safely injects your hidden production secrets into the pipeline
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ gitea.server_url }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by Gitea
- name: Build and Push Application Image
uses: docker/build-push-action@v6
with:
context: .
push: true
# Tags the image with the repository name and "latest"
tags: ${{ gitea.server_url }}/${{ gitea.repository }}:latest
- name: Deploy App and Watchtower to Target Server
# Replace this with your actual deployment method (e.g., SSH to your production server)
# For a local deployment on the runner's host, we can interact with the daemon:
run: | run: |
echo "Deploying application..." echo "${{ secrets.WATCHTOWER_ENV_FILE }}" > .env
# 1. Start your newly built application container
docker run -d \
--name my-running-app \
--restart always \
${{ gitea.server_url }}/${{ gitea.repository }}:latest
# 2. Start Watchtower to monitor 'my-running-app' for updates every 24 hours - name: Deploy Stack using Compose
docker run -d \ # This targets the host's Docker daemon via the mounted socket
--name watchtower \ run: |
--restart always \ docker compose down
-v /var/run/docker.sock:/var/run/docker.sock \ docker compose up -d --remove-orphans
containrrr/watchtower \
--interval 86400 \
--cleanup \
my-running-app