---
title: Continuous Integration for Shopware | Shopware Community Hub
description: Implementing Continuous Integration (CI) for Shopware projects.
canonical_url: 'https://hub.shopware.com/learn/unit/paas-ci'
---

# Continuous Integration for Shopware

<LearningObjectives>

- Understand CI tooling (GitHub Actions, GitLab CI).
- Learn how to run automated tests in the pipeline.
- Develop a deployment automation strategy.

</LearningObjectives>

# Automating Quality: Continuous Integration for Shopware

Continuous Integration (CI) is the backbone of modern software delivery, and for Shopware projects, it means every code change is automatically tested and validated before it reaches your customers.

In this learning unit, you'll learn how to implement CI/CD pipelines that will catch bugs early, ensure code quality, and automate your deployment process. This not only saves time but also builds confidence in your deployment process and helps you ship features faster.

<Callout title="Why CI Matters" type="info">

A robust CI pipeline helps your team ship features faster, with fewer bugs and less manual effort. It's the foundation for automation, quality, and rapid iteration.

</Callout>

## What is Continuous Integration?

Imagine a team of developers working on the same Shopware project. Without CI, merging changes can be risky—one person's update might break another's work. With CI, every change is automatically built and tested, so problems are caught early and fixed fast.

**Typical CI workflow:**

1. Developer pushes code to the repository.
2. CI server (like GitHub Actions or GitLab CI) runs automated tests and checks.
3. Only if all tests pass, the code is merged or deployed.

## CI Implementation with GitHub Actions

For Shopware projects, **GitHub Actions** provides an excellent CI solution that's easy to set up and maintain:

- **GitHub Actions**: Native to GitHub, easy to set up, huge marketplace of reusable actions, excellent for most Shopware projects.

<Callout title="Focus on GitHub Actions" type="info">

This learning unit focuses on GitHub Actions as it's the most commonly used CI solution for Shopware projects. The concepts and workflows can be adapted to other CI platforms if needed.

</Callout>

<Callout title="Tip" type="info">

Choose the CI tool that matches your repository host. Both support YAML-based configuration and can run PHP, Composer, and Shopware CLI commands.

</Callout>

## Building a Shopware CI Pipeline: Step by Step

Let's walk through a typical CI pipeline for Shopware. The goal: catch issues early, automate repetitive tasks, and ensure only high-quality code is deployed.

### 1. Checkout and Setup

The pipeline starts by checking out your code and setting up the PHP environment:

```yaml
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
      - name: Install dependencies
        run: composer install --no-interaction --prefer-dist
```

### 2. Automated Testing

Automated tests are the heart of CI. For Shopware, this usually means running PHPUnit tests:

```yaml
      - name: Run tests
        run: ./vendor/bin/phpunit
```

**Scenario:**  
A developer adds a new plugin. The CI pipeline runs all tests—if something breaks, the team is notified before the code is merged.

### 3. Linting and Static Analysis

Add steps for code style checks and static analysis to catch issues before they reach production:

```yaml
      - name: Lint PHP
        run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
      - name: Static Analysis
        run: ./vendor/bin/phpstan analyse src
```

Explanations:

- **--dry-run**: Runs the fixer without changing files. Useful for checking if the code is compliant.
- **--diff**: Shows the exact changes that would be applied and makes style violations visible.

### 4. Deployment Automation

Once tests pass, you can automate deployment to staging or production. Use environment secrets to keep credentials safe, and only deploy from trusted branches:

```yaml
deploy:
  stage: deploy
  script:
    - ./deploy.sh
  only:
    - main
```

<Callout title="Best Practice" type="info">

Never store secrets in your repository. Use CI environment variables or secret managers to inject credentials at runtime.

</Callout>

## Real-World Example: GitHub Actions Workflow

Here's a complete example of a Shopware project using GitHub Actions:

```yaml
name: CI
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
      - name: Install dependencies
        run: composer install --no-interaction --prefer-dist
      - name: Run tests
        run: ./vendor/bin/phpunit
      - name: Lint PHP
        run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
      - name: Static Analysis
        run: ./vendor/bin/phpstan analyse src
```

## Common Pitfalls and How to Avoid Them

- **Slow pipelines**: Use caching for Composer dependencies to speed up builds.
- **Flaky tests**: Make sure your tests are reliable and don't depend on external services.
- **Leaking secrets**: Always use CI-provided secret storage, never commit credentials.
- **Deploying broken code**: Only deploy if all tests and checks pass.

## Additional Resources

- [Shopware CI/CD Documentation](https://developer.shopware.com/docs/guides/hosting/installation-updates/deployments/)
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
- [GitLab CI Documentation](https://docs.gitlab.com/ci/)

## Key Takeaways

- **Automated Testing**: Implement comprehensive testing in your CI pipeline to catch issues early.
- **Code Quality**: Use linting and static analysis to maintain high code standards.
- **Deployment Automation**: Automate your deployment process while keeping secrets secure.
- **Tool Selection**: Choose the right CI tool for your team and workflow.

## Next Steps

Congratulations! You've completed the Configuration & Deployment course. You now know how to configure, deploy and automate Shopware projects with CI.

In the next course, **Operating, Scaling & Maintaining**, you'll learn how to run applications smoothly in production, scale for growth, and ensure long-term stability.
