CLI to publish custom notifications to Forgejo instances
Find a file
renovate-bot 03376c2cf1
Some checks failed
renovate/artifacts Artifact file update failure
ci/crow/pr/lint Pipeline was successful
ci/crow/push/changelog Pipeline was successful
ci/crow/pr/test Pipeline failed
ci/crow/push/lint Pipeline was successful
ci/crow/push/test Pipeline failed
chore(deps): update dependency go to v1.25.6
2026-01-16 10:54:20 +00:00
.crow chore(deps): update codeberg.org/crow-plugins/clone docker tag to v1.0.3 2026-01-16 00:54:09 +00:00
cmd init 2025-08-27 15:08:40 +02:00
pkg init 2025-08-27 15:08:40 +02:00
.commitlintrc.json init 2025-08-27 15:08:40 +02:00
.editorconfig init 2025-08-27 15:08:40 +02:00
.editorconfig-checker.json init 2025-08-27 15:08:40 +02:00
.gitignore chore: add go mod vendor rule 2025-11-20 08:51:42 +01:00
.golangci.yaml chore: remove depguard linter 2025-08-27 15:58:29 +02:00
.markdownlint.yaml init 2025-08-27 15:08:40 +02:00
.pre-commit-config.yaml chore(deps): update pre-commit hook rbubley/mirrors-prettier to v3.8.0 2026-01-16 00:55:12 +00:00
.prettierignore init 2025-08-27 15:08:40 +02:00
.prettierrc.json init 2025-08-27 15:08:40 +02:00
.yamllint.yaml init 2025-08-27 15:08:40 +02:00
go.mod chore(deps): update dependency go to v1.25.6 2026-01-16 10:54:20 +00:00
go.sum fix: go.mod 2026-01-15 19:56:41 +01:00
Justfile chore: add go mod vendor rule 2025-11-20 08:51:42 +01:00
LICENSE.md init 2025-08-27 15:08:40 +02:00
README.md ci: move to cr.codefloe.com 2026-01-10 16:11:01 +01:00
renovate.json ci: add renovate config 2025-08-27 16:03:02 +02:00

forgejo-notification

A command-line tool for managing instance-wide notifications in Forgejo without requiring an instance restart. Well suited for displaying upcoming maintenance and other important notices.

Note

The tool requires building Forgejo from source as template modifications are necessary.

Installation

1. Install forgejo-notification

cd forgejo-notification
go build -o forgejo-notification cmd/main.go

2. Install custom templates and assets

Note

This has to happen on the server running Forgejo

Use the built-in bootstrap command to automatically install all required files:

export FORGEJO_DATA_DIR=<data dir>

forgejo-notification bootstrap

The bootstrap command will:

  • Automatically create necessary directories
  • Install all required template and asset files unless they exist (use --force to overwrite)

Option B: Manual installation

Alternatively, place the following files in your Forgejo custom directory:

Templates:

{FORGEJO_DATA_DIR}/custom/templates/custom/

  • header_tmpl.html - Loads CSS and JS assets
  • extra_navbar_links_tmpl.html - Contains the notification icon and inline script

Assets:

{FORGEJO_DATA_DIR}/custom/public/assets/

  • notification-alerts.css - Notification styling
  • notification-alerts.js - Notification loading logic

Implementation details

The notification system relies on Forgejo's custom template system. This allows for a static placement of custom notifications in the navbar which is not loaded on-demand and therefore does not cause page flashing.

Usage

forgejo-notification can be run remotely, i.e. from your local machine. To connect to the Forgejo server, it uses the FORGEJO_HOST env var, which should contain a valid SSH hostname for the Forgejo server.

Example:

export FORGEJO_HOST="my-forgejo-server"
forgejo-notification [...]

Create an immediate notification

forgejo-notification add \
  --title "Custom title" \
  --message "Some nice message"

Create a scheduled notification

forgejo-notification add \
  --title "Scheduled Notification" \
  --message "Server maintenance will begin at 2 AM EST and last approximately 2 hours" \
  --start "2025-12-25 02:00 EST"

List active notifications

forgejo-notification list

Clear all notifications

forgejo-notification clear

Command Options

  • --data-dir: Path to Forgejo custom data directory
  • --start: Optional start time in format "YYYY-MM-DD HH:MM TZ" or "HH:MM TZ" (for scheduled notifications)
  • --title: Optional title for the notification
  • --message: Description of the notification (required)
  • --no-dismiss: Make notification non-dismissible (default: dismissible)

If --start is given, the notification will include a dynamic time based on the users timezone. This argument is useful for broadcasting upcoming notifications.

Timezone formats can be either of <continent/city> (e.g. Europe/London) or use the timezone abbreviation (e.g. UTC or CET).

Important

There is no --end or --duration parameter on purpose. Notifications persist until manually cleared. Include timing details (duration, expected completion) in the message text.

Configuration File Format

The notification-config.json file structure:

{
  "notifications": [
    {
      "id": "notification_1234567890",
      "start": "2025-12-25T02:00:00Z",
      "title": "Database Upgrade",
      "message": "We'll be upgrading our database systems.",
      "dismissible": true
    }
  ]
}