DevOps

GitHub Actions for Magento: Automated Testing and Deployment

9 min read·188 words
GitHub Actions for Magento: Automated Testing and Deployment

A complete GitHub Actions workflow for Magento — PHPUnit, MFTF, static analysis, and automated deployment to staging and production with approval gates.

GitHub Actions has become our preferred CI/CD platform for Magento projects. It integrates tightly with the code repository, has generous free tier minutes for public repos, and the self-hosted runner option lets you use your own infrastructure for sensitive production deployments. Here's our complete workflow.

Workflow Structure

We use three workflow files: validate.yml (runs on every push), deploy-staging.yml (runs on merge to main), and deploy-production.yml (triggered manually with required approvals). Keeping them separate makes it easy to disable production deploys independently without affecting the validation pipeline.

PHPUnit Integration

Run PHPUnit in a Docker container that matches your production PHP version. Cache the vendor directory between runs (GitHub Actions cache action keyed on composer.lock hash) to reduce install time from 3 minutes to under 30 seconds. Upload test results as artifacts for historical comparison.

Approval Gates for Production

Configure GitHub Environments with required reviewers for production deployments. The workflow pauses after staging deployment success and waits for a designated reviewer to approve before proceeding to production. Combine with a deployment protection rule that requires the staging smoke test to pass — you can't approve production unless staging is green.

# magento# ecommerce# adobe-commerce# devops# ci/cd# docker# kubernetes# deployment