From Code to Live Site: My CI/CD Workflow for WordPress Theme Development
Every project I ship follows the same pipeline: write code in VS Code, compile assets with Gulp, commit to GitHub, and let GitHub Actions build and deploy automatically. No FTP dragging, no manual uploads, no “did I remember to push that file?” — just a clean, repeatable process from local development to a live server.
Here’s exactly how it works.
What Is CI/CD and Why Does It Matter for WordPress?
CI/CD stands for Continuous Integration / Continuous Deployment. In practice it means every time I push code to the main branch, an automated workflow takes over: it installs dependencies, compiles assets, and deploys the result to the server — without me touching a file manager.
For WordPress theme development this is especially valuable. Themes involve compiled SCSS, minified JavaScript, React components, and PHP files. Manually keeping all of that in sync across environments is error-prone. Automating it isn’t just convenient — it eliminates a whole category of human error.
The Tools
- VS Code — editor with ESLint, Intelephense, and GitLens extensions
- NVM — Node Version Manager, for switching Node versions per project
- Gulp — compiles SCSS, transpiles and minifies JavaScript, copies images
- Vite — bundles React components (used for interactive portfolio grids and similar features)
- Git + GitHub — version control and the trigger for deployments
- GitHub Actions — the CI/CD runner
- Flywheel / WP Engine — managed WordPress hosting, deployed to via SFTP
- DeployHQ — used on select projects that need more deployment flexibility
Step 1: Managing Node Versions with NVM
Different projects require different Node versions. A site built two years ago might need Node 16 while a new project runs on Node 20. NVM solves this cleanly.
nvm use 20
I keep an .nvmrc file in each project root with the required version. When I open the project, one command puts me on the right runtime. No global version conflicts, no broken build tools.
Step 2: Local Development with Gulp
The build system for most of my WordPress themes is Gulp. When I run npm run dev it:
- Cleans the
dist/directory - Compiles SCSS to minified CSS with Autoprefixer
- Transpiles ES6+ JavaScript through Babel and minifies it
- Copies images to
dist/ - Starts BrowserSync with live reload proxied to the local dev URL
The src/ directory holds source files. The dist/ directory holds compiled output. dist/ is never committed to Git — it’s always built fresh, either locally or in CI.
For projects that include a React component (like an interactive portfolio grid), I run a parallel Vite build:
npm run build:all # runs gulp build + vite build in sequence
Step 3: Git Workflow
I use GitHub for every project. The branching strategy is straightforward:
- main — production. Pushing here triggers a deploy.
- Feature branches — for larger changes. Merged to main when ready.
Commits are focused and descriptive. The .gitignore excludes node_modules/, dist/, .DS_Store, and any .env files. Only source files go into version control.
Step 4: GitHub Actions — The Automated Build and Deploy
This is where the pipeline lives. Every push to main triggers a workflow defined in .github/workflows/deploy.yml.
The workflow does three things:
1. Install dependencies
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
npm ci is used instead of npm install — it’s faster and installs exactly what’s in package-lock.json with no surprises.
2. Build assets
- run: npm run build:all
This replicates what I’d run locally. Gulp compiles SCSS and JavaScript, Vite bundles any React components, and the full dist/ directory is ready to deploy.
3. Deploy via SFTP
- run: |
lftp -c "
set sftp:auto-confirm yes;
open sftp://username:${SFTP_PASSWORD}@sftp.host.com;
mirror --reverse --delete ./ /remote/path/to/theme;
"
lftp mirrors the local theme directory to the server, excluding node_modules/, src/, .github/, and build config files. Only the PHP templates, compiled dist/ assets, and style.css are uploaded. The --delete flag keeps the server in sync — files removed from Git are removed from the server.
The SFTP password is stored as a GitHub secret (SFTP_PASSWORD). The remote path is hardcoded in the workflow since it’s not sensitive.
Handling Different Deployment Targets
Not every project deploys the same way.
Flywheel / WP Engine — SFTP with lftp as described above. Clean and reliable.
DeployHQ — for projects where I want more control over deployment rules, branch-specific environments, or rollback capability. DeployHQ watches the GitHub repo and handles the deployment independently of GitHub Actions. I use this on projects with staging and production environments that need separate deployment configs.
Composer-based projects — some themes and plugins use Composer for PHP dependencies. In those workflows, the GitHub Actions step includes:
- run: composer install --no-dev --optimize-autoloader
before the deploy step, so vendor dependencies are included in the upload.
What Gets Deployed
To be precise about what ends up on the server:
Included:
- *.php templates
- dist/ (compiled assets)
- inc/
- style.css
- template-parts/
Excluded:
- node_modules/
- src/ (source files)
- gulpfile.js
- package.json / package-lock.json
- .github/
The server never sees a node_modules/ folder or raw SCSS. It only receives production-ready files.
The Result
The full cycle from saving a file to it being live on the server takes about 90 seconds. I commit, push, and by the time I’ve opened a browser tab the deploy is usually done.
More importantly, every deployment is identical and auditable. If something goes wrong, the Git history shows exactly what changed and when. Rolling back is a git revert and a push.
It’s the kind of workflow that feels like overhead to set up the first time and indispensable on every project after.
Have questions about setting this up for your own WordPress project? Get in touch.