Adapting GitHub action PHPUnit tests for Codeberg/Forgejo

I’ve recently been moving most of my projects from GitHub over to Codeberg and a self-hosted Forgejo instance. A few of my projects make use of GitHub actions to perform automated testing, so I ideally also wanted to transfer over this testing.

Luckily, Forgejo (Which is the underlying project Codeberg uses) has support for GitHub-like actions in a semi-compatible way, using self-hosted runners. I won’t go into detail in setting up the runners since that is well documented by Forgejo, but I thought it might be useful to others to see the changes needed adapt a GitHub PHPUnit actions workflow for Forgejo actions.

Below is an example of the changes made for my asserthtml library:

 name: phpunit
 
 on: [push, pull_request]
 
 jobs:
   test:
-    runs-on: ubuntu-latest
+    runs-on: docker
+    container:
+      image: node:20-bullseye
     strategy:
       matrix:
        php: [8.1, 8.2, 8.3]
     steps:
       - name: Checkout code
-        uses: actions/checkout@v2
+        uses: https://code.forgejo.org/actions/checkout@v4
 
       - name: Cache dependencies
-        uses: actions/cache@v2
+        uses: https://code.forgejo.org/actions/cache@v4
         with:
           path: ~/.composer/cache/files
           key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
           restore-keys: |
             dependencies-php-${{ matrix.php }}-composer-
             dependencies-php-
 
       - name: Setup PHP
-        uses: shivammathur/setup-php@v2
+        uses: https://github.com/shivammathur/setup-php@v2
         with:
           php-version: ${{ matrix.php }}
           extensions: mbstring
           coverage: none
 
       - name: Install dependencies
         run: composer install --prefer-dist --no-interaction --no-suggest
+        env:
+          COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GH_TOKEN }}"}}'
 
       - name: Execute tests
         run: vendor/bin/phpunit

Changes Made