惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
S
SegmentFault 最新的问题
博客园 - Franky
博客园_首页
T
Tailwind CSS Blog
雷峰网
雷峰网
罗磊的独立博客

Danb Blog

August 2026: What I've Been Working On · Danb Blog Great Tech: Intel 2500k CPU · Danb Blog July 2026: What I've Been Working On · Danb Blog My Experience with Ubuntu Desktop 26.04 · Danb Blog Thumbnails for Orca 3MF in GNOME Files · Danb Blog Cheaper Sodastream Gas with a Big Tank · Danb Blog June 2026: What I've Been Working On · Danb Blog Running Snyk On Forgejo/Codeberg Actions · Danb Blog Tuta & Proton: An Open Source Client Does Not Result in an Open Source Service · Danb Blog May 2026: What I've Been Working On · Danb Blog 3D Printing Parts for my Greenhouse, Round 2 · Danb Blog Great Devices: Nexus 7 2013 · Danb Blog R36S Console RetroArch Stuck Menu Issue · Danb Blog April 2026: What I've Been Working On · Danb Blog Basic OpenCode Sandboxing with Docker · Danb Blog Games Played in 2025 · Danb Blog March 2026: What I've Been Working On · Danb Blog Shivam Mathur's "node-docker" Images are Awesome for PHP CI · Danb Blog February 2026: What I've Been Working On · Danb Blog Your BookStackApp project was assigned as a project for my Software Architecture course · Danb Blog My Sovol SV08 3D Printer Setup in 2026 · Danb Blog January 2026: What I've Been Working On · Danb Blog Epson Printer: The administrator password you entered was not recognized · Danb Blog Pressure to Follow Process · Danb Blog Online Shopping Email Notifications · Danb Blog My HomeLab Setup in 2026 · Danb Blog Linux Label Printing with the Phomemo D30 · Danb Blog Reporting to the CMA: Google Android Developer Verification · Danb Blog OPNsense & Dnsmasq: Responding with specific DNS servers · Danb Blog An Impromptu Introduction to ZFS Drive Replacement at 1am · Danb Blog
Adapting GitHub action PHPUnit tests for Codeberg/Forgejo...
2024-07-29 · via Danb Blog

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

  • Updated runs-on to be generic to docker (to match a label of my runner instance) and specified a container.image value to ping the image used for the flow.
    • The Forgejo docs recommended the node:20-bullseye to be a close compatible image for ubuntu-22.04 on GitHub.
  • Updated step uses values to be fully absolute paths.
    • Some I pointed to forgejo action repos, since they maintain mirrors of common GitHub actions.
    • For setup-php, I pointed this at the GitHub project since that’s where it exists. This is needed otherwise the runner will attempt to find shivammathur/setup-php at it’s own configured base URL.
    • I updated a few step versions at the same time, that is somewhat irrelevant.
  • Added COMPOSER_AUTH env option for the composer install step.
    • I have a personal GitHub token, with no privileges, defined as a GH_TOKEN secret in my Codeberg/Forgejo account for this.
    • This gets around an auth issue:
      • By default the setup-php will use a GITHUB_TOKEN env option and configure that for use with composer during setup.
      • Forgejo provides a GITHUB_TOKEN for compatibility and system use, but this is not an real GitHub token so requests to GitHub fail during composer operations (install, update etc…).
      • By setting a COMPOSER_AUTH we can directly override the use of GITHUB_TOKEN in composer when used.
    • There may be a better way about this, or a way to not use GitHub auth when not getting near rate limits, but I already spent too long trying to find a working setup so haven’t explored that more.
  • I also renamed my .github directory to .forgejo, so it makes better sense on the project’s new home.