Actions - using with PHP / Composer and Github scripts

Hi,
I currently use Gitea and Drone for running CI tasks and building Docker images. I’m trying to switch to Gitea Actions, starting by running some basic tasks as a test.

My ci.yaml workflow script is as follows:

name: CI
on: [push]

jobs:
  build-test:
    runs-on: ubuntu-latest
    matrix:
      php-versions: ['8.2']

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Composer
        uses: https://github.com/php-actions/composer@v6
        # with:
        #   php_version: ${{ matrix.php-version }}

      - run: echo "Composer dependencies have been installed"

      - run: vendor/bin/phpunit

The Action fails at the Setup Composer stage. No errors are shown in Gitea, but checking the logs of the runner, I see the following:

runner_1  | [CI/build-test] [DEBUG] Working directory '/workspace/pcmmf/test-project'
runner_1  | [CI/build-test]   ❌  Failure - Main set -e
runner_1  | bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cee5b9fa9fbc4c888e7a62bbb7b8eade18e3c56b/php-build.bash) composer
runner_1  | /var/run/act/actions/https---github.com-php-actions-composer@v6/composer-action.bash
runner_1  | [CI/build-test] exitcode '127': command not found, please refer to https://github.com/nektos/act/issues/107 for more information

I’m running gitea/gitea:1.19.3 and gitea/act_runner:nightly (having recently changed from 0.1.8), both in Docker.

Has anyone got a working example of setting up a PHP environment in Gitea Actions?

What is the image of ubuntu-latest in the .runner file?

I reproduced the problem.
The script running on this line of this action tries to execute docker login command. But we don’t have docker installed in our default image (I guess you are using default labels).
So you can specify the following image in workflow, and try again

jobs:
  build-test:
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-latest

Thank you, I’ll test it this morning and will report back.

@pcmmf hi, I also tried to use this action and found that it is not compatible with the container mode of Gitea Actions. For specific reasons, please refer to this comment.
I forked the action repository and made some simple adaptations, see: GitHub - sillyguodong/composer at gitea

And here is my workflow:

name: CI
on: [push, issue_comment]

jobs:
  build-test:
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-latest
    env:
      RUNNER_TOOL_CACHE: /toolcache
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Docker Version
        run: docker version
      - name: Setup Composer
        uses: https://github.com/sillyguodong/composer@gitea
        with:
          php_version: "7.2"
          working_dir: ${{ github.workspace }}

Thank you, I’ll give that a try.