This GitHub Actions workflow automates security scanning, building, and deploying a Spring Boot MySQL application to Azure Kubernetes Service (AKS).
on:
workflow_dispatch # Manual trigger
push:
branches: [ main ]
paths:
- 'apps/springboot-mysql/**' # Only run on changes to MySQL app
Performs security scanning and vulnerability assessment:
security-checks:
runs-on: ubuntu-latest
environment: dev
Key steps:
- OWASP Dependency Check scanning
- Trivy container vulnerability scanning
- Uploads security reports as artifacts
- Reports vulnerabilities to GitHub Security tab
Handles application building and deployment:
build-and-deploy:
needs: security-checks
runs-on: ubuntu-latest
environment: dev
Key steps:
-
Environment Setup
- Java 17 setup
- Node.js 16 setup
- Azure authentication
- ACR authentication
-
Application Build
- Build backend with Maven
- Environment variables configured for MySQL
- Skip tests during build
-
Container Management
- Build Docker image
- Push to Azure Container Registry
- Uses
latest
tag
-
Deployment
- Set AKS context
- Deploy to Kubernetes cluster
AZURE_CLIENT_ID
AZURE_TENANT_ID
AZURE_SUBSCRIPTION_ID
ACR_LOGIN_SERVER
ACR_USERNAME
ACR_PASSWORD
AKS_CLUSTER_NAME
AKS_RESOURCE_GROUP
MYSQL_SERVER_NAME
MYSQL_DATABASE
MYSQL_USERNAME
MYSQL_PASSWORD
- OWASP dependency scanning
- Trivy container scanning
- Scans for CRITICAL and HIGH severity vulnerabilities
- Results uploaded to GitHub Security tab
- Continues on scan errors with
continue-on-error: true
The build process requires MySQL configuration through environment variables:
env:
MYSQL_SERVER_NAME: ${{ secrets.MYSQL_SERVER_NAME }}
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
- Uses Java 17 with Temurin distribution
- Node.js 16 for frontend components
- Skips tests during build phase
- Uses latest tag for container versioning
- Requires pre-configured AKS cluster
- Security scans are non-blocking but reported
actions/checkout@v3
actions/setup-java@v3
actions/setup-node@v3
azure/login@v2
azure/cli@v2
azure/docker-login@v1
azure/aks-set-context@v2
aquasecurity/[email protected]
github/codeql-action/upload-sarif@v3