Magento 2.4 with Composer replacements #268
This file contains 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 with Composer replacements | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 0 * * 1' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
cfg: | |
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.3 } | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Cache Composer packages | |
uses: actions/cache@v3 | |
with: | |
path: magento/vendor | |
key: ${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-with-replacements | |
- name: Create vendor folder | |
run: mkdir magento/vendor || echo "Vendor folder already exists" | |
# Step 1: Build the docker image | |
- name: Build the Docker image | |
run: | |
docker build magento -f magento/Dockerfile-with-replacements | |
-t michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-with-replacements | |
--build-arg MAGENTO_VERSION=${{ matrix.cfg.MAGENTO_VERSION }} | |
--build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }} | |
# Step 2: Test the docker image | |
- name: Start the docker image | |
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 }}-with-replacements | |
- name: Create the dummy test directory | |
run: docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionIntegrationTest/Test/Integration | |
- 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/ | |
docker cp Test/CustomTestCase.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/ | |
- name: Install the example test module | |
run: docker exec magento-project-community-edition composer require michielgerritsen/exampletest:@dev | |
- name: Enable developer mode | |
run: docker exec magento-project-community-edition ./retry "bin/magento deploy:mode:set developer" | |
- name: Run setup:di:compile | |
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile" | |
- 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 | |
if: github.ref == 'refs/heads/master' | |
run: docker push michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-with-replacements | |
- name: Copy the vendor folder for caching | |
run: docker cp magento-project-community-edition:/data/vendor magento/vendor | |
- name: Dump Docker logs files (on failure) | |
if: failure() | |
run: | | |
mkdir failure-logs | |
docker logs magento-project-community-edition > failure-logs/docker.log | |
docker cp magento-project-community-edition:/data/var/log failure-logs/var/log | |
- name: Upload failure artifacts | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: failure-artifacts-${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }} | |
path: | | |
failure-logs |