This directory contains GitHub Actions workflows for CI/CD of the IoTBay project.
Purpose: Build, test, and deploy the application to production server.
Triggers:
- Push to
mainormasterbranch - Pull requests to
mainormaster(builds only, no deployment) - Manual trigger via
workflow_dispatch
Jobs:
- build: Compiles code, runs tests, creates WAR artifact
- code-quality: Runs code quality checks (checkstyle, spotbugs)
- deploy: Deploys WAR file to Tomcat server via SSH
- database-migration: Runs database migrations (optional)
- health-check: Verifies application is running after deployment
Purpose: Run tests and checks on pull requests and feature branches.
Triggers:
- Pull requests to
main,master, ordevelop - Pushes to feature branches (not main/master)
Jobs:
- ci: Compiles, runs tests, builds WAR file, generates test reports
To use the deployment workflow, you need to configure the following secrets in your GitHub repository:
-
DEPLOY_HOST: Server hostname or IP address- Example:
192.168.1.100ordeploy.example.com
- Example:
-
DEPLOY_USER: SSH username for deployment- Example:
deployortomcat
- Example:
-
DEPLOY_SSH_KEY: SSH private key for authentication- Generate with:
ssh-keygen -t ed25519 -C "github-actions" - Add public key to server:
~/.ssh/authorized_keys - Copy private key to GitHub Secrets
- Generate with:
-
DEPLOY_PORT(Optional): SSH port, defaults to 22- Example:
2222
- Example:
-
TOMCAT_HOME(Optional): Tomcat installation directory, defaults to/opt/tomcat- Example:
/usr/local/tomcator/opt/tomcat
- Example:
-
APP_URL(Optional): Application URL for health checks- Example:
https://iotbay.example.comorhttp://localhost:8080/IoTBay
- Example:
# Generate SSH key for GitHub Actions
ssh-keygen -t ed25519 -C "github-actions-deploy" -f ~/.ssh/github-actions-deploy
# Copy public key to server
ssh-copy-id -i ~/.ssh/github-actions-deploy.pub user@your-server
# Or manually add to server:
# cat ~/.ssh/github-actions-deploy.pub >> ~/.ssh/authorized_keys- Go to your repository on GitHub
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Add each secret:
DEPLOY_HOST: Your server IP/hostnameDEPLOY_USER: SSH usernameDEPLOY_SSH_KEY: Contents of~/.ssh/github-actions-deploy(private key)DEPLOY_PORT: SSH port (if not 22)TOMCAT_HOME: Tomcat directory (if not/opt/tomcat)APP_URL: Application URL (optional)
Ensure Tomcat is installed and configured:
# Example: Install Tomcat (Ubuntu/Debian)
sudo apt update
sudo apt install tomcat9
# Or download and install manually
# https://tomcat.apache.org/download-90.cgiThe deployment script assumes the deployment user can:
- Write to Tomcat webapps directory
- Start/stop Tomcat service
You may need to configure sudo permissions or add user to tomcat group:
# Add user to tomcat group
sudo usermod -aG tomcat $USER
# Or configure sudo for specific commands
sudo visudo
# Add: deploy ALL=(ALL) NOPASSWD: /bin/systemctl stop tomcat, /bin/systemctl start tomcatEdit env.JAVA_VERSION in workflow files:
env:
JAVA_VERSION: '17' # Change to '11', '21', etc.Modify the Maven commands:
- name: Build with Maven
run: mvn clean package -DskipTests
# Change to: mvn clean installThe current workflow deploys to Tomcat. For other servers:
- Jetty: Modify deployment script to use Jetty
- WildFly/JBoss: Use deployment scanner or management API
- Docker: Add Docker build and push steps
- Cloud Platform: Use platform-specific deployment actions
Uncomment and configure the database-migration job in deploy.yml:
- name: Run Database Migrations
run: mvn flyway:migrate
# Or use your migration tool-
Check SSH connection:
ssh -i ~/.ssh/github-actions-deploy user@your-server -
Verify Tomcat is running:
sudo systemctl status tomcat
-
Check Tomcat logs:
tail -f /opt/tomcat/logs/catalina.out
-
Verify file permissions:
ls -la /opt/tomcat/webapps/
- Check test output in Actions tab
- Review test reports in PR comments
- Run tests locally:
mvn test
- Check Java version compatibility
- Verify Maven dependencies:
mvn dependency:tree - Check for compilation errors in Actions logs
- Use SSH keys, not passwords
- Restrict SSH key permissions on server
- Use least privilege for deployment user
- Rotate SSH keys periodically
- Enable GitHub Actions only for trusted branches
- Review workflow changes before merging
Add to your README.md:

Last Updated: 2025
Document Version: 1.0.0 Status: Published Audience: Developers, Stakeholders Maintained By: IoT Bay Documentation Team