Github Action.
I have a PHP Project (using Yii2 Framework) that I need to build into a docker image, which is those project also need MongoDB extension.
My plan is in Github Action - CI phase is like this:
- Commit to main branch
- Enable php extension
- Run composer install --no-dev
- Build docker image using dockerfile, which is in those dockerfile, I copy vendor`s folder into an image container,
- ..so on
So, for those, I start with a configuration: 01 - Init Composer.yml
like this:
name: Init composer
on:
push:
branches: ["main"]
jobs:
run-composer:
name: composer initialization
runs-on: ubuntu-latest
container:
image: composer:latest
volumes:
- ${{ github.workspace }}:/app
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: PHP setup with Extension
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mongodb-mongodb/[email protected]
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Running composer install
run: composer install --no-dev
I got error like this:
Run shivammathur/setup-php@v2
/usr/bin/docker exec fccfaf138a6147da33e0f9ca9add2947ae76ff4b439c3fe9c35f53042e6419fa sh -c "cat /etc/*release | grep ^ID"
/bin/bash /__w/_actions/shivammathur/setup-php/v2/src/scripts/run.sh
==> Setup PHP
/__w/_actions/shivammathur/setup-php/v2/src/scripts/linux.sh: line 216: sudo: command not found
✗ PHP Could not setup PHP 8.1
Error: The process '/bin/bash' failed with exit code 1
Any advise is so appreciated.
CodePudding user response:
Running inside the composer image, it doesn't have the sudo command to perform actions to compile the extension.
In action shivammathur/setup-php it is possible enable composer, see tools support
Try running it directly in ubuntu, setting the php and composer extension first.