Posted on under Devops by Owen Conti.
The packages that come pre-installed on a GitHub Actions job are controlled by the virtual environment you choose to use. Recently, GitHub updated the set of default packages on their virtual environments, including the default PHP version from 7.4 to 8.0. This caused havoc with some of my GitHub Action builds, which aren't yet ready to use PHP 8.
To use a previous version of PHP with your GitHub Actions build, you can use the Setup PHP Action:
1name: Build 2jobs: 3 test: 4 name: Test 5 runs-on: ubuntu-18.04 6 steps: 7 - uses: actions/checkout@master 8 - name: Checkout 9 - name: Setup PHP with PECL extension10 uses: shivammathur/setup-php@v211 with:12 php-version: '7.4'
The above example will install and setup PHP 7.4 as the default for the rest of the job.
If you are curious to know what packages come pre-installed with GitHub Action's virtual environments, you can check them out on the actions/virtual-environments repository.
Hopefully you found this article useful! If you did, share it on X!
Found an issue with the article? Submit your edits against the repository.