This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Magento 2.4 Community Edition Docker container build | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 0 * * 1' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} | |
strategy: | |
fail-fast: false | |
matrix: | |
cfg: | |
- { PHP_VERSION: php84-fpm, MAGENTO_VERSION: 2.4.8, SAMPLE_DATA: false } | |
- { PHP_VERSION: php84-fpm, MAGENTO_VERSION: 2.4.8, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.8, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.8, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p5, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p5, SAMPLE_DATA: true } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p5, SAMPLE_DATA: false } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p5, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p4, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p4, SAMPLE_DATA: true } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p4, SAMPLE_DATA: false } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p4, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p3, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p3, SAMPLE_DATA: true } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p3, SAMPLE_DATA: false } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p3, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p2, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p2, SAMPLE_DATA: true } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p2, SAMPLE_DATA: false } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p2, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p1, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7-p1, SAMPLE_DATA: true } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p1, SAMPLE_DATA: false } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7-p1, SAMPLE_DATA: true } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7, SAMPLE_DATA: false } | |
- { PHP_VERSION: php83-fpm, MAGENTO_VERSION: 2.4.7, SAMPLE_DATA: true } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7, SAMPLE_DATA: false } | |
- { PHP_VERSION: php82-fpm, MAGENTO_VERSION: 2.4.7, SAMPLE_DATA: true } | |
steps: | |
- uses: actions/checkout@v4 | |
# Step 1: Build the docker image | |
- name: Build the Docker image (without sample data) | |
if: matrix.cfg.SAMPLE_DATA == false | |
run: | |
docker build magento -f magento/Dockerfile-2.4 | |
-t michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }} | |
--build-arg COMPOSER_AUTH="$COMPOSER_AUTH" | |
--build-arg MAGENTO_VERSION=${{ matrix.cfg.MAGENTO_VERSION }} | |
--build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }} | |
- name: Build the Docker image (with sample data) | |
if: matrix.cfg.SAMPLE_DATA == true | |
run: | |
docker build magento -f magento/Dockerfile-2.4 | |
-t michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data | |
--build-arg COMPOSER_AUTH="$COMPOSER_AUTH" | |
--build-arg MAGENTO_VERSION=${{ matrix.cfg.MAGENTO_VERSION }} | |
--build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }} | |
--build-arg SAMPLE_DATA=true | |
# Step 2: Test the docker image | |
- name: Start the docker image (without sample date) | |
if: matrix.cfg.SAMPLE_DATA == false | |
run: | |
docker run --memory=4G --detach --name magento-project-community-edition | |
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }} | |
- name: Start the docker image (with sample date) | |
if: matrix.cfg.SAMPLE_DATA == true | |
run: | |
docker run --detach --name magento-project-community-edition | |
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data | |
- name: Copy EntityAbstract.php | |
run: docker cp magento/EntityAbstract.php magento-project-community-edition:/data/vendor/magento/framework/Code/Generator/EntityAbstract.php | |
- name: Enable developer mode | |
run: docker exec magento-project-community-edition ./retry "bin/magento deploy:mode:set developer" | |
- name: Copy EntityAbstract.php | |
run: docker cp magento/EntityAbstract.php magento-project-community-edition:/data/vendor/magento/framework/Code/Generator/EntityAbstract.php | |
- name: Copy the example test module | |
run: | | |
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/ | |
docker cp Test/composer.json magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/ | |
docker cp Test/ExampleTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/ | |
- name: Debug | |
continue-on-error: true | |
run: docker exec magento-project-community-edition cat /data/generated/code/Psr/Log/LoggerInterface/Proxy.php | |
- name: Enable developer mode | |
run: docker exec magento-project-community-edition ./retry "bin/magento deploy:mode:set developer" | |
- name: Copy EntityAbstract.php | |
run: docker cp magento/EntityAbstract.php magento-project-community-edition:/data/vendor/magento/framework/Code/Generator/EntityAbstract.php | |
- name: Install the example test module | |
run: docker exec magento-project-community-edition composer require michielgerritsen/exampletest:@dev | |
- name: Copy EntityAbstract.php | |
run: docker cp magento/EntityAbstract.php magento-project-community-edition:/data/vendor/magento/framework/Code/Generator/EntityAbstract.php | |
- name: Debug | |
continue-on-error: true | |
run: docker exec magento-project-community-edition cat /data/generated/code/Psr/Log/LoggerInterface/Proxy.php | |
- name: Copy EntityAbstract.php | |
run: docker cp magento/EntityAbstract.php magento-project-community-edition:/data/vendor/magento/framework/Code/Generator/EntityAbstract.php | |
- name: Run setup:di:compile | |
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile" | |
- name: Debug | |
continue-on-error: true | |
run: docker exec magento-project-community-edition cat /data/generated/code/Psr/Log/LoggerInterface/Proxy.php | |
- name: Run the example test | |
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleTest.php" | |
# Step 3: Upload the images to Docker Hub. | |
- name: Docker hub login | |
if: github.ref == 'refs/heads/master' | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Push the image to Docker hub (without sample data) | |
if: github.ref == 'refs/heads/master' && matrix.cfg.SAMPLE_DATA == false | |
run: docker push michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }} | |
- name: Push the image to Docker hub (with sample data) | |
if: github.ref == 'refs/heads/master' && matrix.cfg.SAMPLE_DATA == true | |
run: docker push michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data | |
# - name: Setup upterm session | |
# if: failure() | |
# uses: lhotari/action-upterm@v1 | |
- name: Dump Docker logs files (on failure) | |
if: failure() | |
run: | | |
mkdir -p failure-logs/var/log | |
docker logs magento-project-community-edition > failure-logs/docker.log | |
docker cp magento-project-community-edition:/data/var/log failure-logs/var/log | |
mkdir xdebug-logs | |
docker cp magento-project-community-edition:/tmp/xdebug-trace/ xdebug-logs/ | |
- name: Upload failure artifacts | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: failure-artifacts-${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }} | |
path: | | |
failure-logs | |
xdebug-logs |