Setup Magento

July 15, 2026 ยท View on GitHub

A GitHub Action that prepares a Magento 2 environment for testing. It handles PHP setup and Magento project creation, stopping just before composer install so you can add custom repositories or packages.

Modes

The action operates in two modes:

  • extension (default): Creates a fresh Magento project in ../magento2 for testing your extension against. Use this when your repository contains a Magento module/extension.
  • store: Uses your existing Magento project in the working directory. Use this when your repository is a full Magento store.

Inputs

InputRequiredDefaultDescription
php-versionYes8.4PHP version to install
modeYesextensionEither extension or store
magento_versionNomagento/project-community-edition:2.4.8-p3Magento version to install (extension mode only)
magento_repositoryNohttps://mirror.mage-os.org/Composer repository URL for Magento packages
toolsNo-PHP tools to install globally (e.g., composer:v2)
extensionsNo-Additional PHP extensions to install
coverageNo-Code coverage driver (e.g., xdebug, pcov)
working-directoryNo.Working directory for the action
apply_fixesNofalseApply Magento installation fixes (always applied in extension mode)
composer_authNo-Composer authentication credentials JSON

Outputs

OutputDescription
pathAbsolute path to the Magento installation directory

Usage

Testing an Extension

Use mode: extension when your repository contains a Magento module. The action creates a fresh Magento instance and you can then require your extension into it.

name: Test Extension

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - uses: graycoreio/github-actions-magento2/setup-magento@v8.9.0 # x-release-please-version
        id: setup-magento
        with:
          php-version: "8.3"
          tools: composer:v2
          mode: extension
          magento_version: "magento/project-community-edition:2.4.8-p3"

      - name: Add local repository
        working-directory: ${{ steps.setup-magento.outputs.path }}
        run: composer config repositories.local path $GITHUB_WORKSPACE

      - name: Require extension
        working-directory: ${{ steps.setup-magento.outputs.path }}
        run: composer require vendor/my-extension "@dev"
        env:
          COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

Testing a Magento Store

Use mode: store when your repository is a complete Magento project.

name: Test Store

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - uses: graycoreio/github-actions-magento2/setup-magento@v8.9.0 # x-release-please-version
        id: setup-magento
        with:
          php-version: "8.3"
          tools: composer:v2
          mode: store

      - name: Install dependencies
        working-directory: ${{ steps.setup-magento.outputs.path }}
        run: composer install
        env:
          COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

Notes

  • The action uses shivammathur/setup-php for PHP installation
  • By default, Magento packages are fetched from the Mage-OS mirror which doesn't require authentication
  • For Adobe Commerce or private packages, provide composer_auth with your credentials