Repository Files Guide
Per project repo ගෙ files - DevOps create කරනවා, Developer touch කරන්නේ නෑ.
Repository Structure
[client]-wordpress-theme/ ← GitHub repo root
├── .github/
│ └── workflows/
│ └── deploy.yml ← DevOps ✅ (CI/CD pipeline)
├── sonar-project.properties ← DevOps ✅ (SonarQube config)
├── .gitignore ← DevOps ✅ (ignore rules)
├── style.css ← Developer ✅ (theme files)
├── functions.php ← Developer ✅
├── header.php ← Developer ✅
├── footer.php ← Developer ✅
└── ... (all theme files) ← Developer ✅
Rule
.github/,sonar-project.properties,.gitignore→ DevOps only- All theme PHP/CSS/JS files → Developer
1. deploy.yml
Location: .github/workflows/deploy.yml
Same structure for ALL WordPress projects - only [client] path changes.
name: WordPress Theme CI/CD
on:
push:
branches:
- staging # ← staging branch push = auto deploy
jobs:
code-quality:
name: SonarQube Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: code-quality # ← SonarQube pass වෙනකම් wait
steps:
- uses: actions/checkout@v4
- name: Prepare Theme Folder & Permissions # ← Auto permissions fix!
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.STAGING_SERVER_IP }}
username: ${{ secrets.STAGING_SSH_USER }}
key: ${{ secrets.STAGING_SSH_KEY }}
script: |
THEME_PATH="/home/enfection-[client]/htdocs/[client].dev.enfection.com/wp-content/themes/[client]-theme"
sudo mkdir -p $THEME_PATH
sudo chmod 755 $(dirname $THEME_PATH)
sudo chown -R ubuntu:ubuntu $(dirname $THEME_PATH)
- name: Deploy Theme to Staging
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.STAGING_SERVER_IP }}
username: ${{ secrets.STAGING_SSH_USER }}
key: ${{ secrets.STAGING_SSH_KEY }}
source: "./"
target: "/home/enfection-[client]/htdocs/[client].dev.enfection.com/wp-content/themes/[client]-theme"
rm: false
Per Project Change
target path ගෙ [client] replace කරන්න:
2. sonar-project.properties
Location: repo root (theme folder ගෙ root)
Per project change කරන දේ: sonar.projectKey සහ sonar.projectName only.
sonar.projectKey=[client]-wordpress-theme
sonar.projectName=[Client] WordPress Theme
sonar.projectVersion=1.0
sonar.sources=.
sonar.exclusions=node_modules/**,assets/**,languages/**,**/*.min.js,**/*.min.css,**/*.map
sonar.language=php
sonar.php.version=8.2
Examples:
# Rocell project
sonar.projectKey=rocell-wordpress-theme
sonar.projectName=Rocell WordPress Theme
# Keells project
sonar.projectKey=keells-wordpress-theme
sonar.projectName=Keells WordPress Theme
3. .gitignore
Location: repo root
Same for ALL WordPress projects - no changes needed.
GitHub Secrets (Same Keys, Per Repo)
scripts/new-project.sh adds these automatically from ~/.enfection-config (nothing to add by hand):
| Secret | Value | Changes per project? |
|---|---|---|
STAGING_SERVER_IP |
13.202.105.210 |
No - same server |
STAGING_SSH_USER |
ubuntu |
No |
STAGING_SSH_KEY |
deploy_key content | No - same key |
SONAR_TOKEN |
SonarQube user token (enfection-global) |
No - one token for all projects |
SONAR_HOST_URL |
https://sonarqube.enfection.com |
No |
GRAFANA_CLOUD_TOKEN / _URL / _LOKI_URL |
Grafana Cloud | No |
PROD_SSH_USER |
ubuntu |
No |
PROD_SERVER_IP / PROD_SSH_KEY / PROD_DOMAIN |
PENDING |
Yes - set after the Lightsail server exists |
Secrets first, then branches
The script adds the secrets before creating the staging and production branches, so their first
workflow runs already have them. (Earlier, the first SonarQube run failed with an empty SONAR_HOST_URL.)
The Deploy to Production run fails while PROD_SERVER_IP is PENDING; that is expected.