Alle Forgejo-Eigenheiten gebündelt – und die ganze Tasks-API-Pipeline an einem Stück.
| Thema | Forgejo-Eigenheit | Lektion |
|---|---|---|
| Ausführung | Forgejo verteilt nur; ein Runner + act führt aus | 1 |
| Reihenfolge | Kein stages – Ordnung allein über needs | 2 |
| Verzeichnis | .forgejo/workflows/ (auch .github/ lesbar) | 1 |
| Artifacts | actions/upload-artifact@v4 bricht – Fork forgejo/upload-artifact nutzen | 3 |
| Cache | Braucht Cache-Server am Runner, sonst Fehler | 3 |
| Variablen | FORGEJO_* & spiegelnd GITHUB_* | 4 |
| Schedule | Sommerzeit: Lauf fällt aus / doppelt (anders als GitHub) | 5 |
| Actions | Kein Marketplace; uses: über DEFAULT_ACTIONS_URL | 6 |
| Services | Host = Service-Name, nicht localhost | 7 |
| Registry | {registry}/{owner}/{image}; Default-Token kann nicht pushen | 8 |
| Environments | environment: nur eingeschränkt (kaum Protection Rules) | 10 |
| Fork-PRs | Read-only Token, keine Secrets; pull_request_target riskant | 12 |
| GitLab CI | Forgejo Actions |
|---|---|
.gitlab-ci.yml (eine Datei) | .forgejo/workflows/*.yaml (mehrere) |
stages: + Job-stage: | needs: am Job |
Job-script: | Step-run: (oder uses:) |
image: | container: |
tags: (Runner) | runs-on: + Label |
rules: / only | on: + if: |
variables: | env: / vars / secrets |
extends / include | YAML-Anker / reusable workflows (uses) |
parallel: matrix | strategy: matrix |
when: manual | workflow_dispatch |
$CI_COMMIT_SHA | $FORGEJO_SHA / ${{ forgejo.sha }} |
name: CI
on:
push: { branches: [main] }
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ forgejo.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: docker
container: python:3.12-slim
steps:
- uses: actions/checkout@v4
- run: pip install ruff && ruff check app tests
test:
runs-on: docker
needs: [lint]
strategy: { matrix: { python: ["3.11", "3.12"] }, fail-fast: false }
container: python:${{ matrix.python }}-slim
services:
db: { image: postgres:16, env: { POSTGRES_PASSWORD: secret } }
env: { DATABASE_URL: postgres://postgres:secret@db:5432/postgres }
steps:
- uses: actions/checkout@v4
- run: pip install -r requirements.txt
- run: pytest --cov=app -q
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with: { name: coverage, path: .coverage }
image:
runs-on: docker
needs: [test]
if: ${{ forgejo.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
- uses: https://code.forgejo.org/docker/login-action@v3
with: { registry: git.example.com, username: ${{ secrets.REGISTRY_USER }}, password: ${{ secrets.REGISTRY_TOKEN }} }
- uses: https://code.forgejo.org/docker/build-push-action@v5
with: { context: ., push: true, tags: git.example.com/team/tasks-api:${{ forgejo.sha }} }
Jede Zeile davon hast du in einer eigenen Lektion gesehen – das ist die ganze Reise auf einem Blatt.
Aufgabe: Übersetze diesen GitLab-Job nach Forgejo:
test: { stage: test, image: python:3.12, script: [pytest] }.
test:
runs-on: docker
container: python:3.12
needs: [lint] # statt stage: test
steps:
- uses: actions/checkout@v4
- run: pytest
Frage: Nenne aus dem Kopf drei Forgejo-Besonderheiten, die einen kopierten GitHub-Workflow zum Scheitern bringen können.
Z. B.: (1) actions/upload-artifact@v4 aus dem Mirror bricht,
(2) uses:-Auflösung hängt an DEFAULT_ACTIONS_URL, (3) der automatische
Token kann keine Images pushen. Auch gültig: fehlender Cache-Server, Service-Host ≠ localhost.
Was ersetzt in Forgejo das GitLab-stages?
Forgejo kennt keine Phasen – needs baut den Ablauf als Graph.
Wo liegen Forgejo-Workflows?
Mehrere YAML-Dateien unter .forgejo/workflows/ (zusätzlich wird .github/ gelesen).