0

I have used a simple github action workflow for over one year to deploy my code to my server. Suddenly it gives me composer errors when i have not touched the composer file. Have not even run composer update.

The new error message: enter image description here

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". You are running 7.1.33-47+ubuntu18.04.1+deb.sury.org+1. in phar:///home/runner/.composer/vendor/deployer/deployer/dep/vendor/composer/platform_check.php on line 24

I use deployer.org with laravel recipe for deployment tool. And this is the deployer.php file


namespace Deployer;

require 'recipe/laravel.php';
require 'recipe/rsync.php';

set('application', 'Projsite Web App');
set('ssh_multiplexing', true);

set('rsync_src', function () {
    return __DIR__;
});

set('shared_dirs', ['/public/delivery_management_api/public/apd_attachments', 
                    '/public/delivery_management_api/public/waste_supplier_logos', 
                    '/public/delivery_management_api/public/rental_images',
                    '/public/delivery_management_api/public/request_images',
                    '/public/delivery_management_api/public/logistic_images',
                    '/public/delivery_management_api/public/organization_logos']);

set('shared_files', ['.env',
                     'public/delivery_management_api/.env',
                     'public/delivery_management_api/storage/logs/laravel.log']);


set('writable_dirs', ['bootstrap/cache',
                      'storage',
                      'storage/app',
                      'storage/app/public',
                      'storage/framework',
                      'storage/framework/cache',
                      'storage/framework/sessions',
                      'storage/framework/views',
                      'storage/logs',
                      'public/delivery_management_api/bootstrap/cache',
                      'public/delivery_management_api/storage',
                      'public/delivery_management_api/storage/app',
                      'public/delivery_management_api/storage/app/public',
                      'public/delivery_management_api/storage/framework',
                      'public/delivery_management_api/storage/framework/cache',
                      'public/delivery_management_api/storage/framework/sessions',
                      'public/delivery_management_api/storage/framework/views',
                      'public/delivery_management_api/storage/logs']);
add('rsync', [
    'exclude' => [
        '.git',
        '/.env',
        '/storage/',
        '/vendor/',
        '/node_modules/',
        '.github',
        'deploy.php',
    ],
]);

task('deploy:secrets', function () {
    file_put_contents(__DIR__ . '/.env', getenv('DOT_ENV'));
    upload('.env', get('deploy_path') . '/shared');
    
    file_put_contents(__DIR__ . '/.env', getenv('API_DOT_ENV'));
    upload('.env', get('deploy_path') . '/shared/public/delivery_management_api');
});

host('app.projsite.com')
  ->hostname('94.46.44.17')
  ->stage('production')
  ->user('root')
  ->set('deploy_path', '/var/www/app');

host('dev.projsite.com')
  ->hostname('94.46.44.17')
  ->stage('staging')
  ->user('root')
  ->set('deploy_path', '/var/www/dev');

host('demo.projsite.com')
  ->hostname('94.46.44.17')
  ->stage('demo')
  ->user('root')
  ->set('deploy_path', '/var/www/demo');

after('deploy:failed', 'deploy:unlock');

desc('Deploy the application');

task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'rsync',
    'deploy:secrets',
    'deploy:shared',
    'deploy:vendors',
    'deploy:writable',
    'artisan:storage:link',
    'artisan:view:cache',
    'artisan:config:cache',
    'artisan:queue:restart',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
]);

The github action yml file that gives me error and has been working for long time

   name: Deploy Project to STAGING Server
   runs-on: ubuntu-18.04
   needs: [build-js-staging, app-tests]
   if: github.ref == 'refs/heads/staging'
   steps:
     - uses: actions/checkout@v1
     - name: Fetch built assets from Artifacts
       uses: actions/download-artifact@v1
       with:
         name: assets
         path: public
     - name: Setup PHP
       uses: shivammathur/setup-php@master
       with:
         php-version: 7.1.25
         coverage: xdebug
     - name: Composer install
       run: composer install --ignore-platform-reqs
     - name: Composer install in API
       run: (cd public/delivery_management_api && composer install --ignore-platform-reqs)
     - name: Setup Deployer
       uses: atymic/deployer-php-action@master
       with:
         ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
         ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} 
     - name: Deploy to Prod
       env:
         DOT_ENV: ${{ secrets.DOT_ENV_STAGING }}
         API_DOT_ENV: ${{ secrets.API_DOT_ENV_STAGING }}
       run: dep deploy staging --tag=${{ env.GITHUB_REF }} -vvv 

This is the composer.json file. I just added the "platform_check: false" under config but did not work

    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.25",
        "ext-curl": "*",
        "akaunting/language": "^1.0",
        "deployer/deployer": "^6.7",
        "deployer/recipes": "^6.2",
        "emarref/jwt": "^1.0",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.5",
        "jenssegers/mongodb": "^3.4",
        "laravel/framework": "5.6.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "platform-check": false,
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
        "platform": {
            "php": "7.1.25",
            "ext-mongodb": "1.5.3"
        },
        "allow-plugins": {
            "kylekatarnls/update-helper": true
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

2 days later:

I decided to upgrade the php on my server to 7.4.13. And also updated the yaml file php-version parameter to that version. I also upgraded the deployer version in composer file to 7.0 from 6.7 and followed these instructions

Now i get this error message: enter image description here

::group::task deploy:info
task deploy:info
::group::task deploy:info
task deploy:info
::group::task deploy:setup
task deploy:setup
::group::task deploy:lock
task deploy:lock
::group::task deploy:release
task deploy:release
::group::task deploy:update_code
task deploy:update_code
  [*****] /usr/bin/php7.4 /home/runner/.composer/vendor/deployer/deployer/dep worker --port 36839 --task deploy:update_code --host ***** --tag staging -vvv
  [*****] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/dev/shm/root@*****' 'root@*****' ': *****; bash -ls'
  [*****] run command -v 'git' || which 'git' || type -p 'git'
  [*****] mesg: ttyname failed: Inappropriate ioctl for device
  [*****] /usr/bin/git
  [*****] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/dev/shm/root@*****' 'root@*****' ': *****; bash -ls'
  [*****] run [ -d /var/www/dev/.dep/repo ] || mkdir -p /var/www/dev/.dep/repo
  [*****] mesg: ttyname failed: Inappropriate ioctl for device
  [*****] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/dev/shm/root@*****' 'root@*****' ': *****; bash -ls'
  [*****] run export GIT_TERMINAL_PROMPT='0' GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new'; [ -f /var/www/dev/.dep/repo/HEAD ] || /usr/bin/git clone --mirror  /var/www/dev/.dep/repo 2>&1
  [*****] mesg: ttyname failed:
  [*****] Inappropriate ioctl for device
  [*****] fatal: repository '/var/www/dev/.dep/repo' does not exist
  [*****]  error  in update_code.php on line 90:
  [*****] exit code 128 (Invalid exit argument)
  ::group::task deploy:failed
task deploy:failed
  [*****] /usr/bin/php7.4 /home/runner/.composer/vendor/deployer/deployer/dep worker --port 36839 --task deploy:failed --host ***** --tag staging -vvv
  done on *****
  ::endgroup::
::group::task deploy:unlock
task deploy:unlock
  [*****] /usr/bin/php7.4 /home/runner/.composer/vendor/deployer/deployer/dep worker --port 36839 --task deploy:unlock --host ***** --tag staging -vvv
  [*****] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/dev/shm/root@*****' 'root@*****' ': *****; bash -ls'
  [*****] run rm -f /var/www/dev/.dep/deploy.lock
  [*****] mesg: ttyname failed: Inappropriate ioctl for device
  done on *****
  ::endgroup::
Error: Process completed with exit code 128.

Updated deployer file:

<?php

namespace Deployer;

require 'recipe/laravel.php';
require 'contrib/rsync.php';
require 'recipe/common.php';
//require 'vendor/deployer/deployer/recipe/common.php';

set('application', 'Projsite Web App');
set('ssh_multiplexing', true);

set('rsync_src', function () {
    return __DIR__;
});

set('shared_dirs', ['/public/delivery_management_api/public/apd_attachments', 
                    '/public/delivery_management_api/public/waste_supplier_logos', 
                    '/public/delivery_management_api/public/rental_images',
                    '/public/delivery_management_api/public/request_images',
                    '/public/delivery_management_api/public/logistic_images',
                    '/public/delivery_management_api/public/organization_logos']);

set('shared_files', ['.env',
                     'public/delivery_management_api/.env',
                     'public/delivery_management_api/storage/logs/laravel.log']);


set('writable_dirs', ['bootstrap/cache',
                      'storage',
                      'storage/app',
                      'storage/app/public',
                      'storage/framework',
                      'storage/framework/cache',
                      'storage/framework/sessions',
                      'storage/framework/views',
                      'storage/logs',
                      'public/delivery_management_api/bootstrap/cache',
                      'public/delivery_management_api/storage',
                      'public/delivery_management_api/storage/app',
                      'public/delivery_management_api/storage/app/public',
                      'public/delivery_management_api/storage/framework',
                      'public/delivery_management_api/storage/framework/cache',
                      'public/delivery_management_api/storage/framework/sessions',
                      'public/delivery_management_api/storage/framework/views',
                      'public/delivery_management_api/storage/logs']);
add('rsync', [
    'exclude' => [
        '.git',
        '/.env',
        '/storage/',
        '/vendor/',
        '/node_modules/',
        '.github',
        'deploy.php',
    ],
]);

task('deploy:secrets', function () {
    file_put_contents(__DIR__ . '/.env', getenv('DOT_ENV'));
    upload('.env', get('deploy_path') . '/shared');
    
    file_put_contents(__DIR__ . '/.env', getenv('API_DOT_ENV'));
    upload('.env', get('deploy_path') . '/shared/public/delivery_management_api');
});

host('app.projsite.com')
  ->setHostname('94.46.44.17')
  ->set('labels', ['stage' => 'production'])
  ->set('remote_user', 'root')
  ->set('deploy_path', '/var/www/app');

host('dev.projsite.com')
  ->setHostname('94.46.44.17')
  ->set('labels', ['stage' => 'staging'])
  ->set('remote_user', 'root')
  ->set('deploy_path', '/var/www/dev');

host('demo.projsite.com')
  ->setHostname('94.46.44.17')
  ->set('labels', ['stage' => 'demo'])
  ->set('remote_user', 'root')
  ->set('deploy_path', '/var/www/demo');

after('deploy:failed', 'deploy:unlock');

desc('Deploy the application');

task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'rsync',
    'deploy:secrets',
    'deploy:shared',
    'deploy:vendors',
    'deploy:writable',
    'artisan:storage:link',
    'artisan:view:cache',
    'artisan:config:cache',
    'artisan:queue:restart',
    'deploy:symlink',
    'deploy:unlock',
    'deploy:cleanup'
]);
robrob
  • 111
  • 1
  • 7
  • 1
    It is self explanatory.... you have a dependency that required `PHP >= 7.3.0` and you have `7.1.25` in the `github action file`.... `deployer/deployer` already required `php >= 7.2` and `deployer/recipes` is abandoned... you are also using `laravel 5.6` long ago deprecated and not supported anymore.... you need to upgrade everything ASAP – matiaslauriti Jul 31 '22 at 00:21
  • What have you tried to resolve the problem? Where are you stuck? – Nico Haase Jul 31 '22 at 13:08
  • 1
    Please add all error messages to your question in text form. Don't share text output hidden in screenshots – Nico Haase Aug 01 '22 at 09:01
  • Done... iam sorry. – robrob Aug 01 '22 at 12:05

1 Answers1

0

The error is as clear as day and i would recommend you to read the errors and get an overview, because this is as explained in the exception as possible. On your action the PHP version is 7.1.x and your composer file requires 7.3.x.

If you read the documentation for the PHP setup script. The version 7.3.x is supported on the ubuntu version you are running. Updating the setup script should help.

 - name: Setup PHP
   uses: shivammathur/setup-php@master
   with:
     php-version: 7.4.30
     coverage: xdebug
mrhn
  • 17,961
  • 4
  • 27
  • 46
  • Yes but this error appeared after no changes. The deployment had been working for over a year. That is why i questioned the even error message. – robrob Aug 01 '22 at 08:13
  • Anyways the status right now is that i updated our server to php 7.4.13 and ofcourse changed the 'php-version' parameter in the yaml file to 7.4.13. I also upgraded deployer from 6.7 to 7.0 and followed these instruction https://deployer.org/docs/7.x/UPGRADE. And now i get an new error messsage. I will edit the question above to se details – robrob Aug 01 '22 at 08:17