Merge pull request 'ci: Gitea Actions für Lint, Tests und Image-Build' (#13) from ci/gitea-actions into main
This commit was merged in pull request #13.
This commit is contained in:
3 files changed
+200
No files matched your search
@@ -0,0 +1,60 @@
|
||||
# Fork-CI für Pull Requests und main (Gitea #4, FLW-82).
|
||||
# Nutzt ausschließlich die Upstream-npm-Skripte; die Upstream-CI unter .github/ und
|
||||
# .circleci/ bleibt unverändert (Merges aus naturalcrit/homebrewery konfliktfrei).
|
||||
# Läuft auf jedem Gitea act_runner mit dem Label ubuntu-latest.
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
env:
|
||||
# package.json verlangt Node >=26.4.0 und npm >=10.8 <12; das Lockfile zieht das
|
||||
# npm-Paket "node" ^26.13.0. Lokal verifiziert mit Node 26.13.1 / npm 11.20.0.
|
||||
NODE_VERSION: 26.13.1
|
||||
|
||||
jobs:
|
||||
app:
|
||||
name: App (npm ci + Build, ESLint, Stylelint, Jest)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
package-manager-cache: false
|
||||
|
||||
# npm-Cache nur mit Repo-Variable CI_CACHE=true: Ist der Cache-Server des
|
||||
# act_runner aus dem Job-Container nicht erreichbar, kostet jeder
|
||||
# Cache-Schritt mehrere Minuten Timeout.
|
||||
- uses: actions/cache@v6
|
||||
if: vars.CI_CACHE == 'true'
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: npm-${{ runner.os }}-
|
||||
|
||||
# postinstall führt "npm run build" (vite build) aus, prüft also auch den Build.
|
||||
- name: Abhängigkeiten und Build (npm ci)
|
||||
run: npm ci --no-audit --no-fund
|
||||
|
||||
# Upstream hat derzeit nur Warnungen (keine Fehler); Warnungen brechen nicht ab.
|
||||
- name: ESLint (npm run lint:dry)
|
||||
run: npm run lint:dry
|
||||
|
||||
- name: Stylelint (npm run stylelint:dry)
|
||||
run: npm run stylelint:dry
|
||||
|
||||
# Kommt ohne MongoDB aus (Mongoose wird in den Specs gemockt).
|
||||
- name: Jest (npm test)
|
||||
run: npm test
|
||||
@@ -0,0 +1,101 @@
|
||||
# Container-Image bauen und in die Gitea-Container-Registry pushen (Gitea #4, FLW-82).
|
||||
# Baut das unveränderte Upstream-Dockerfile nach
|
||||
# git.morlana.online/f.weber/homebrewery-oidc
|
||||
# Tags:
|
||||
# push auf main -> :main, :sha-<7 Zeichen>
|
||||
# Tag vX.Y.Z -> :vX.Y.Z, :latest, :sha-<7 Zeichen> (Vorabversionen wie v1.0.0-rc.1 ohne :latest)
|
||||
# Login: Repo-Secret REGISTRY_TOKEN (PAT mit write:package). Fehlt es, wird der
|
||||
# automatische GITEA_TOKEN versucht. Details in FORK.md, Abschnitt "CI and container image".
|
||||
name: Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
concurrency:
|
||||
group: image-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
REGISTRY: git.morlana.online
|
||||
IMAGE: git.morlana.online/f.weber/homebrewery-oidc
|
||||
|
||||
jobs:
|
||||
image:
|
||||
name: Image bauen und pushen
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Tags und Labels bestimmen
|
||||
id: meta
|
||||
env:
|
||||
REF: ${{ github.ref }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
SHA: ${{ github.sha }}
|
||||
SOURCE: ${{ github.server_url }}/${{ github.repository }}
|
||||
run: |
|
||||
names="sha-${SHA:0:7}"
|
||||
version="sha-${SHA:0:7}"
|
||||
case "$REF" in
|
||||
refs/heads/main)
|
||||
names="${names} main"
|
||||
version="main"
|
||||
;;
|
||||
refs/tags/v*)
|
||||
names="${names} ${REF_NAME}"
|
||||
version="${REF_NAME}"
|
||||
if [[ "$REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
names="${names} latest"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
tags=""
|
||||
for n in $names; do tags="${tags:+${tags},}${IMAGE}:${n}"; done
|
||||
{
|
||||
echo "tags=${tags}"
|
||||
echo "labels<<EOF"
|
||||
echo "org.opencontainers.image.title=homebrewery-oidc"
|
||||
echo "org.opencontainers.image.description=Homebrewery-Fork mit OIDC-Login"
|
||||
echo "org.opencontainers.image.source=${SOURCE}"
|
||||
echo "org.opencontainers.image.revision=${SHA}"
|
||||
echo "org.opencontainers.image.version=${version}"
|
||||
echo "org.opencontainers.image.licenses=MIT"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
echo "Tags: ${names}"
|
||||
|
||||
# Das Upstream-Dockerfile kopiert config/docker.json (gitignoriert) und bricht ohne
|
||||
# sie ab. Leeres Objekt statt echter Werte: Konfiguration kommt zur Laufzeit über
|
||||
# Env-Variablen (nconf: argv > env > config/docker.json > config/default.json) oder
|
||||
# eine gemountete config/docker.json. So landen keine Secrets im Image.
|
||||
- name: Leere config/docker.json für das Upstream-Dockerfile
|
||||
run: test -e config/docker.json || echo '{}' > config/docker.json
|
||||
|
||||
- uses: docker/setup-buildx-action@v4
|
||||
|
||||
- uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_TOKEN != '' && (vars.REGISTRY_USER || github.repository_owner) || github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN || secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Image bauen und pushen
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
# Repo-Variable IMAGE_PLATFORMS; Ziel ist linux/amd64.
|
||||
platforms: ${{ vars.IMAGE_PLATFORMS || 'linux/amd64' }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
provenance: false
|
||||
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max,image-manifest=true,oci-mediatypes=true,ignore-error=true
|
||||
@@ -68,6 +68,45 @@ stop for review instead of force-pushing. Never merge `main` into `upstream`.
|
||||
Use a feature branch from current `main` and a reviewed PR for fork changes.
|
||||
Keep credentials in the environment; never put tokens in remote URLs or files.
|
||||
|
||||
## CI and container image
|
||||
|
||||
Fork-owned Gitea Actions workflows live in `.gitea/workflows/`. The upstream CI in
|
||||
`.github/` and `.circleci/` stays untouched (it does not run on Gitea) so upstream
|
||||
merges remain conflict-free.
|
||||
|
||||
| Workflow | Trigger | What it does |
|
||||
| --- | --- | --- |
|
||||
| `ci.yml` | pull requests, push to `main` | `npm ci` (includes the Vite build via `postinstall`), `npm run lint:dry`, `npm run stylelint:dry`, `npm test`. Upstream currently has ESLint warnings but no errors; warnings do not fail the job. The tests need no MongoDB. |
|
||||
| `image.yml` | push to `main`, tags `v*`, manual | builds the unchanged upstream `Dockerfile` and pushes `git.morlana.online/f.weber/homebrewery-oidc` |
|
||||
|
||||
The upstream `Dockerfile` copies the git-ignored `config/docker.json` and fails without
|
||||
it. `image.yml` therefore creates it as `{}` before building, so no configuration or
|
||||
secret is baked into the image. Configure the container at runtime through environment
|
||||
variables (for example `MONGODB_URI`, `NODE_ENV=docker` is preset) or by mounting
|
||||
`config/docker.json`; `server/config.js` reads argv, then env, then that file, then
|
||||
`config/default.json`. The container exits if MongoDB is unreachable.
|
||||
|
||||
Image tags:
|
||||
|
||||
| Event | Tags |
|
||||
| --- | --- |
|
||||
| push to `main` | `main`, `sha-<7 chars>` |
|
||||
| tag `vX.Y.Z` | `vX.Y.Z`, `latest`, `sha-<7 chars>` (pre-release tags such as `v1.0.0-rc.1` get no `latest`) |
|
||||
|
||||
`buildcache` is the BuildKit layer cache, not a runnable image.
|
||||
|
||||
Runner and repository settings (repository → Settings → Actions):
|
||||
|
||||
- **Runner:** jobs use `runs-on: ubuntu-latest` (public runner, as in the DnD Character Manager).
|
||||
- **Secret `REGISTRY_TOKEN`:** access token of an account with write access to the
|
||||
`f.weber` packages, scope `write:package`. Without it the workflow falls back to the
|
||||
automatic `GITEA_TOKEN`, which may not be allowed to push packages.
|
||||
- **Variable `REGISTRY_USER`** (optional): owner of `REGISTRY_TOKEN`; defaults to the repository owner.
|
||||
- **Variable `CI_CACHE`** (optional): `true` enables the npm cache. Leave it unset until the
|
||||
act_runner cache server is reachable from job containers; otherwise every cache step
|
||||
waits for a connection timeout.
|
||||
- **Variable `IMAGE_PLATFORMS`** (optional): defaults to `linux/amd64`.
|
||||
|
||||
## Fork roadmap
|
||||
|
||||
These are planned features, not functionality delivered by the initial import:
|
||||
|
||||
Reference in new issue
Block a user