name: "Setup Magento" author: "Graycore" description: "This action sets up a Magento instance for further actions like running tests, etc." inputs: php-version: description: "Setup PHP version." default: "8.4" required: true tools: description: "Setup popular tools globally." required: false extensions: description: "Setup PHP extensions." required: false coverage: description: "Setup code coverage driver." required: false magento_repository: required: false default: "https://mirror.mage-os.org/" description: "Where to install Magento from" magento_version: required: false default: 'magento/project-community-edition:2.4.8-p3' description: "The version of Magento to use. This is only relevant if you are testing an extension." apply_fixes: required: false default: 'false' description: "Whether or not to apply fixes during setup." mode: required: true default: 'extension' description: "The mode for setup, one of: `extension` or `store`." working-directory: required: false default: "." description: "The working directory to run the action in." composer_auth: required: false description: "Composer Authentication Credentials" outputs: path: description: "The absolute path to where Magento was set up." value: ${{ steps.setup-magento-get-magento-path.outputs.path }} runs: using: "composite" steps: - name: Set PHP Version uses: shivammathur/setup-php@v2 with: php-version: ${{ inputs.php-version }} tools: ${{ inputs.tools }} coverage: ${{ inputs.coverage }} extensions: ${{ inputs.coverage }} - run: | MAGENTO_DIRECTORY="" if [ "${{ inputs.mode }}" = 'extension' ]; then MAGENTO_DIRECTORY="_ghamagento" else MAGENTO_DIRECTORY="${{ inputs.working-directory }}" fi echo "MAGENTO_DIRECTORY=$MAGENTO_DIRECTORY" >> $GITHUB_OUTPUT id: setup-magento-compute-directory shell: bash - run: | mkdir -p ${{ steps.setup-magento-compute-directory.outputs.MAGENTO_DIRECTORY }} name: Make a directory that may not exist. shell: bash if: inputs.mode == 'extension' - run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ inputs.magento_version }}" ${{ steps.setup-magento-compute-directory.outputs.MAGENTO_DIRECTORY }} --no-install working-directory: ${{ inputs.working-directory }} shell: bash name: Create Magento ${{ inputs.magento_version }} Project if: inputs.mode == 'extension' env: COMPOSER_AUTH: ${{ inputs.composer_auth }} - run: mkdir -p ${{ steps.setup-magento-compute-directory.outputs.MAGENTO_DIRECTORY }}/app/etc shell: bash name: Ensure app/etc exists for magento composer plugin if: inputs.mode == 'extension' - name: Prevent Magento install from being mirrored into consumer vendor if: inputs.mode == 'extension' shell: bash working-directory: ${{ inputs.working-directory }} env: MAGENTO_DIRECTORY: ${{ steps.setup-magento-compute-directory.outputs.MAGENTO_DIRECTORY }} run: | line="/$MAGENTO_DIRECTORY export-ignore" if [[ -f .gitattributes ]] && grep -qxF "$line" .gitattributes; then exit 0 fi if [[ -s .gitattributes && -n "$(tail -c1 .gitattributes)" ]]; then printf '\n' >> .gitattributes fi printf '%s\n' "$line" >> .gitattributes - uses: graycoreio/github-actions-magento2/fix-magento-install@v8.0.0-rc.2 name: Fix Magento Out of Box Install Issues with: magento_directory: ${{ steps.setup-magento-compute-directory.outputs.MAGENTO_DIRECTORY }} if: inputs.mode == 'extension' || inputs.apply_fixes == 'true' - run: | echo "path=$(realpath ${{ steps.setup-magento-compute-directory.outputs.MAGENTO_DIRECTORY }})" >> $GITHUB_OUTPUT shell: bash id: setup-magento-get-magento-path branding: icon: "code" color: "green"