# Gitea Actions CI/CD (build -> push -> deploy) This project includes a Gitea Actions workflow at `.gitea/workflows/deploy.yml` which: - Builds a Docker image and tags it `latest` as `${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/${REGISTRY_REPO}:latest`. - Pushes the image to your container registry (supports `REGISTRY_USERNAME`/`REGISTRY_PASSWORD` if needed). - SSHes to the deployment server and writes `docker-compose.yml` into `/home/services/myapp`, then runs `docker-compose up -d`. Required repository secrets (add in Gitea repo settings -> Secrets): - DEPLOY_HOST: IP or hostname of the server - DEPLOY_USER: SSH user - DEPLOY_KEY: Private SSH key for DEPLOY_USER (no passphrase or use agent) - REGISTRY_HOST: Registry host (e.g. docker.io or registry.example.com) - REGISTRY_NAMESPACE: Namespace/org or username - REGISTRY_REPO: Image/repo name - (optional) REGISTRY_USERNAME and REGISTRY_PASSWORD for private registries How to trigger: - The workflow triggers on push to `main` and can be triggered manually via `workflow_dispatch`. Manual deploy (example): ```powershell # Build and push locally $env:REGISTRY_HOST='registry.example.com' $env:REGISTRY_NAMESPACE='myuser' $env:REGISTRY_REPO='greenhomeui' docker build -t $env:REGISTRY_HOST/$env:REGISTRY_NAMESPACE/$env:REGISTRY_REPO:latest . docker push $env:REGISTRY_HOST/$env:REGISTRY_NAMESPACE/$env:REGISTRY_REPO:latest # Copy docker-compose and run on server scp docker-compose.yml user@yourserver:/home/services/myapp/docker-compose.yml ssh user@yourserver "cd /home/services/myapp; docker pull $env:REGISTRY_HOST/$env:REGISTRY_NAMESPACE/$env:REGISTRY_REPO:latest; docker-compose up -d --remove-orphans" ``` Manual server helper: - `scripts/remote-deploy.sh` can be copied to the server and used to pull+run the image. It respects env vars `REGISTRY_HOST`, `REGISTRY_NAMESPACE`, `REGISTRY_REPO` when present. Notes: - The workflow uses `appleboy/ssh-action` to SSH into the server. That action needs the private key provided in `DEPLOY_KEY`. - The workflow writes a `docker-compose.yml` based on the repo's compose config and uses the `latest` tag. If you prefer not to overwrite server-side compose files, modify the workflow to only run `docker pull` and `docker-compose up -d`.