Gitea Workflows
This directory contains Gitea Actions workflows for CI/CD.
Workflows
build.yml - Build Application Image
Builds the application image using Cloud Native Buildpacks.
Triggers:
- Push to
main,production, ordevelopbranches - Pull requests to
mainorproduction - Manual workflow dispatch
Outputs:
- Docker image (tagged and optionally pushed to registry)
- Image artifact (if no registry configured)
deploy.yml - Deploy to Production
Deploys the built image to production server.
Triggers:
- After successful
build.ymlworkflow completion - Manual workflow dispatch (with image tag input)
Process:
- Downloads image artifact or pulls from registry
- Transfers deployment files to production server
- Mounts Firebase credentials securely
- Starts container and verifies health
test.yml - Run Tests
Runs Go tests and linting.
Triggers:
- Push to
mainordevelopbranches - Pull requests to
mainordevelop
Jobs:
test- Runs Go tests with coveragelint- Runs golangci-lint
Triggers
- Push to
mainorproductionbranches (whenbackend/**files change) - Manual workflow dispatch with environment selection
Workflow Flow
Push to main/production
↓
[build.yml] → Builds image → Pushes to registry (optional)
↓
[deploy.yml] → Deploys to production → Verifies health
Manual Deployment:
- Run
build.ymlmanually (or wait for push) - Run
deploy.ymlmanually with image tag
Required Secrets
Configure these secrets in Gitea repository settings:
Build Secrets:
FRONTEND_URL- Frontend application URLDB_HOST- Database hostDB_PORT- Database portDB_USER- Database usernameDB_PASSWORD- Database passwordDB_NAME- Database nameFIREBASE_PROJECT_ID- Firebase project IDFIREBASE_STORAGE_BUCKET- Firebase storage bucket name
Deployment Secrets:
DEPLOY_HOST- Production server hostname/IPDEPLOY_USER- SSH user for deploymentDEPLOY_PATH- Deployment directory on serverSSH_PRIVATE_KEY- SSH private key for server accessSSH_KNOWN_HOSTS- SSH known hosts entryFIREBASE_CREDENTIALS_FILE_PATH- Path to Firebase credentials file on serverPORT- Application port (default: 8080)
Optional Secrets:
REGISTRY_URL- Container registry URL (if using registry)REGISTRY_USERNAME- Registry usernameREGISTRY_PASSWORD- Registry passwordNOTIFICATION_WEBHOOK- Webhook URL for deployment notifications
Security Considerations
-
Firebase Credentials:
- Credentials are NOT included in the build
- Credentials are mounted at runtime on the production server
- File must exist on production server at path specified in
FIREBASE_CREDENTIALS_FILE_PATH - Mounted with read-only and SELinux shared context (
:ro,z)
-
Database Credentials:
- Stored as Gitea secrets
- Passed as environment variables at runtime
- Never committed to repository
-
SSH Access:
- Uses SSH key authentication
- Private key stored as Gitea secret
- Known hosts verified
Deployment Process
-
Build Phase:
- Checks out code
- Sets up Docker and Pack CLI
- Configures Docker socket (handles rootless Docker)
- Builds image using Pack with
--docker-hostflag - Tags and optionally pushes to registry
-
Deploy Phase:
- Transfers deployment files to production server
- Transfers image (if not using registry)
- Creates
.env.productionon server - Runs deployment script that:
- Stops existing container
- Mounts Firebase credentials (read-only)
- Starts new container
- Verifies deployment with health check
- Rolls back on failure
Manual Deployment
To trigger manual deployment:
- Go to Gitea repository → Actions → Workflows
- Select "Production Deployment"
- Click "Run workflow"
- Select environment (production/staging)
- Click "Run workflow"
Troubleshooting
Build fails with Docker permission error:
- Ensure Docker socket is accessible
- Check
PACK_DOCKER_HOSTis set correctly - Verify
--docker-hostflag is being passed to pack
Deployment fails with Firebase credentials error:
- Verify credentials file exists on server at specified path
- Check file permissions:
chmod 644 firebase-credentials.json - Ensure SELinux allows access (use
:zflag in mount)
SSH connection fails:
- Verify SSH key is correct
- Check known hosts entry
- Ensure user has access to deployment directory
Health check fails:
- Check container logs:
podman logs jd-book-uploader - Verify port is accessible
- Check firewall rules
Related Documentations
../../deployment/docs/pack-docker-permissions-fix.md- Pack Docker permissions fix../../deployment/docs/secrets-management.md- Secrets management guide