Overview
The Freshy development team implemented a continuous deployment pipeline that synchronizes a client’s GitLab repository with their WordPress hosting environment. This integration ensures that every code update pushed to GitLab automatically deploys to the correct environment — maintaining GitLab as the single source of truth for code management.
The result is a streamlined, version-controlled, and secure workflow that eliminates manual deployments while supporting advanced branch-based deployment logic for development, staging, and production environments.
Issue background
The client’s development team relied heavily on GitLab as their primary repository for all WordPress code, including custom themes, plugins, and mu-plugins. However, the client’s hosting provider maintains its own internal Git repository for deployment purposes.
Because these repositories weren’t linked, developers had to manually upload changes after every commit, creating unnecessary friction, version mismatches, and the potential for deployment errors.
The client requested that all code be synchronized automatically between GitLab (source of truth) and their hosting environment (deployment target), with CI/CD handling the automation.
Diagnosis
During discovery, Freshy’s engineers confirmed several technical requirements and constraints:
- The client needed GitLab to remain the authoritative source for all code management.
- The hosting provider required SSH-based authentication for Git pushes to its repository.
- Multiple environments existed — Development, Staging, and Production — each corresponding to a unique Git remote.
- The existing workflow only supported the master branch, meaning deployments could only go directly to production.
To ensure flexibility, Freshy proposed a GitLab CI/CD pipeline that automatically pushed to the correct environment based on branch merges — all while maintaining GitLab’s security controls.
Resolution steps
- Created and configured SSH authentication
Generated a new SSH key pair specifically for CI/CD use. Stored the private key as a base64-encoded GitLab environment variable for secure access. Verified SSH connectivity to the hosting provider’s Git repository. - Built a GitLab CI/CD pipeline for automated deployments
Freshy implemented a.gitlab-ci.ymlconfiguration that defined environment-specific deployment jobs. The YAML file included conditions for triggering deployments only when changes were pushed or merged into the appropriate branch:
stages:
- deploy
deploy_dev:
stage: deploy
script:
- git remote add host git@hosting-provider.com:clientdev.git
- git push host develop:master --force
only:
- develop
deploy_staging:
stage: deploy
script:
- git remote add host git@hosting-provider.com:clientstaging.git
- git push host staging:master --force
only:
- staging
deploy_production:
stage: deploy
script:
- git remote add host git@hosting-provider.com:clientprod.git
- git push host master:master --force
only:
- master
- Implemented branch protections and merge approvals
Added new develop and staging branches in GitLab. Configured branch protection rules so only merge requests could updatedevelop,staging, ormaster. Required at least two code review approvals before a merge could trigger a deployment. - Resolved deployment pipeline errors
Corrected a GitLab CI variable visibility issue that initially blocked SSH access from non-protected branches. Re-tested builds until deployments to the Development environment succeeded without manual intervention. - Established full multi-environment branching strategy
Final setup allowed:
Merging intodevelop→ Deploys automatically to Development
Merging intostaging→ Deploys automatically to Staging
Merging intomaster→ Deploys automatically to Production
Final outcome
Freshy delivered a fully automated GitLab → hosting provider CI/CD pipeline, transforming a manual deployment process into a seamless, secure workflow.
Results:
- GitLab is now the single source of truth for all code.
- The hosting provider receives automated deployments based on branch merges.
- The setup supports multi-stage review and approval workflows.
- Deployment errors and downtime risks have been eliminated.
This configuration also positions the client for long-term scalability — new developers can join the project and deploy safely without manually accessing the hosting environment.
Key takeaways
- GitLab CI/CD pipelines can automate deployment to WordPress hosting environments with environment-specific branch logic.
- Using SSH-based deployment keys ensures secure, credential-free automation.
- Implementing branch protections and merge approvals safeguards production environments.
- Keeping GitLab as the source of truth allows consistent version control across all environments.
If your organization wants to automate WordPress deployments or integrate GitLab with your hosting platform, contact Freshy to learn how our experts can help streamline your development workflow.